Skip to content

Commit 80337e3

Browse files
committed
fix: fixes for unique items, pattern properties and additional properties
1 parent 1861371 commit 80337e3

File tree

3 files changed

+5
-2
lines changed

3 files changed

+5
-2
lines changed

src/JsonSchema/Constraints/Drafts/Draft06/AdditionalPropertiesConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
4747

4848
foreach ($additionalProperties as $key => $_) {
4949
foreach ($patterns as $pattern) {
50-
if (preg_match("/{$pattern}/", $key)) {
50+
if (preg_match("/{$pattern}/", (string) $key)) {
5151
unset($additionalProperties[$key]);
5252
break;
5353
}

src/JsonSchema/Constraints/Drafts/Draft06/PatternPropertiesConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
3535

3636
foreach ($properties as $propertyName => $propertyValue) {
3737
foreach ($schema->patternProperties as $patternPropertyRegex => $patternPropertySchema) {
38-
if (preg_match('/' . str_replace('/', '\/', $patternPropertyRegex) . '/', $propertyName)) {
38+
if (preg_match('/' . str_replace('/', '\/', $patternPropertyRegex) . '/', (string) $propertyName)) {
3939
$schemaConstraint = $this->factory->createInstanceFor('schema');
4040
$schemaConstraint->check($propertyValue, $patternPropertySchema, $path, $i);
4141
if ($schemaConstraint->isValid()) {

src/JsonSchema/Constraints/Drafts/Draft06/UniqueItemsConstraint.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public function check(&$value, $schema = null, ?JsonPointer $path = null, $i = n
2525
if (!property_exists($schema, 'uniqueItems')) {
2626
return;
2727
}
28+
if (!is_array($value)) {
29+
return;
30+
}
2831

2932
if ($schema->uniqueItems !== true) {
3033
// If unique items not is true duplicates are allowed.

0 commit comments

Comments
 (0)