diff --git a/src/Schema/Keywords/Pattern.php b/src/Schema/Keywords/Pattern.php index ccf91655..be405cc2 100644 --- a/src/Schema/Keywords/Pattern.php +++ b/src/Schema/Keywords/Pattern.php @@ -38,7 +38,7 @@ public function validate($data, string $pattern): void throw InvalidSchema::becauseDefensiveSchemaValidationFailed($e); } - $pattern = sprintf('#%s#', str_replace('#', '\#', $pattern)); + $pattern = sprintf('#%s#u', str_replace('#', '\#', $pattern)); if (! preg_match($pattern, $data)) { throw KeywordMismatch::fromKeyword('pattern', $data, sprintf('Data does not match pattern \'%s\'', $pattern)); diff --git a/tests/Schema/Keywords/PatternTest.php b/tests/Schema/Keywords/PatternTest.php index 2a33bdca..3079a44e 100644 --- a/tests/Schema/Keywords/PatternTest.php +++ b/tests/Schema/Keywords/PatternTest.php @@ -22,6 +22,7 @@ public function validDataProvider(): array ['1foo1', '1foo1'], // Tests adding anchors when first and last character is same with numbers ['^#\d+$', '#123'], // Tests adding anchors to string which has # ['^#(\d+)#$', '#123#'], // Tests adding anchors to string which has multiple# + ['^[А-Я]{2}$', 'ДГ'], // Tests patterns with Unicode ]; }