Skip to content

Commit

Permalink
unicode is a range
Browse files Browse the repository at this point in the history
  • Loading branch information
goetas committed Aug 30, 2023
1 parent 505fef8 commit 726686d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/Jms/YamlValidatorConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,11 @@ private function loadValidatorType(array &$property, Type $type, $arrayized = fa
// initial support for https://www.w3.org/TR/xsd-unicode-blocknames/
// not supported by standard php regex implementation
$regexPattern = strtr($item['value'], [
'\p{IsBasicLatin}' => '\x00-\x7F',
'\p{IsIsBasicLatin}' => '\x{0000}-\x{007F}',
'\p{IsLatin-1Supplement}' => '\x{0080}-\x{00FF}',
'\p{IsLatinExtended-A}' => '\x{0100}-\x{024F}',
'\p{IsLatinExtended-B}' => '\x{0180}-\x{024F}',
'\p{IsBasicLatin}' => '[\x00-\x7F]',
'\p{IsIsBasicLatin}' => '[\x{0000}-\x{007F}]',
'\p{IsLatin-1Supplement}' => '[\x{0080}-\x{00FF}]',
'\p{IsLatinExtended-A}' => '[\x{0100}-\x{024F}]',
'\p{IsLatinExtended-B}' => '[\x{0180}-\x{024F}]',
]);
$rules[] = [
'Regex' => ['pattern' => "~{$regexPattern}~"],
Expand Down
4 changes: 2 additions & 2 deletions tests/Converter/Validator/Xsd2ValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,11 @@ public function getRestrictionsValidations()
],
// pattern / Regex
[
'<xs:pattern value="[\\p{IsBasicLatin}\\p{IsLatin-1Supplement}]+"/>',
'<xs:pattern value="\\p{IsBasicLatin}\\p{IsLatin-1Supplement}"/>',
[
[
'Regex' => [
'pattern' => '~[\\x00-\\x7F\\x{0080}-\\x{00FF}]+~',
'pattern' => '~[\\x00-\\x7F][\\x{0080}-\\x{00FF}]~',
'groups' => ['xsd_rules'],
],
],
Expand Down

0 comments on commit 726686d

Please sign in to comment.