Skip to content

Commit 5ec2d42

Browse files
committed
Add support for additionalProperties set to true
1 parent 01949f6 commit 5ec2d42

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/JsonSchema/Constraints/Object.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ public function validateElement($element, $matches, $objectDefinition = null, $p
8282

8383
// additional properties defined
8484
if (!in_array($i, $matches) && $additionalProp && !$definition) {
85-
$this->checkUndefined($value, $additionalProp, $path, $i);
85+
if ($additionalProp === true) {
86+
$this->checkUndefined($value, null, $path, $i);
87+
} else {
88+
$this->checkUndefined($value, $additionalProp, $path, $i);
89+
}
8690
}
8791

8892
// property requires presence of another

tests/JsonSchema/Tests/Constraints/AdditionalPropertiesTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ public function getValidTests()
124124
},
125125
"additionalProperties": {"type":"string"}
126126
}'
127+
),
128+
array(
129+
'{
130+
"prop":"1",
131+
"additionalProp":[]
132+
}',
133+
'{
134+
"type":"object",
135+
"properties":{
136+
"prop":{"type":"string"}
137+
},
138+
"additionalProperties": true
139+
}'
127140
)
128141
);
129142
}

0 commit comments

Comments
 (0)