Skip to content

Commit

Permalink
Add unicode (#142)
Browse files Browse the repository at this point in the history
* Add unicode
* Fix
* Update PatternTest
  • Loading branch information
galiaf1987 authored Sep 28, 2021
1 parent c4e1cbd commit d246868
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Schema/Keywords/Pattern.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
1 change: 1 addition & 0 deletions tests/Schema/Keywords/PatternTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
];
}

Expand Down

0 comments on commit d246868

Please sign in to comment.