diff --git a/src/JsonSchema/Constraints/Undefined.php b/src/JsonSchema/Constraints/Undefined.php index 16e92a1f..ca0800eb 100644 --- a/src/JsonSchema/Constraints/Undefined.php +++ b/src/JsonSchema/Constraints/Undefined.php @@ -195,6 +195,11 @@ protected function validateCommonProperties($value, $schema = null, $path = null */ protected function validateOfProperties($value, $schema, $path, $i = "") { + // Verify type + if ($value instanceof Undefined) { + return; + } + if (isset($schema->allOf)) { $isValid = true; foreach ($schema->allOf as $allOf) { diff --git a/tests/JsonSchema/Tests/Constraints/OfPropertiesTest.php b/tests/JsonSchema/Tests/Constraints/OfPropertiesTest.php new file mode 100644 index 00000000..90d3734c --- /dev/null +++ b/tests/JsonSchema/Tests/Constraints/OfPropertiesTest.php @@ -0,0 +1,92 @@ + "prop2", + "message" => "array value found, but a number is required", + ), + array( + "property" => "prop2", + "message" => "array value found, but a string is required", + ), + array( + "property" => "prop2", + "message" => "failed to match exactly one schema", + ), + ), + ), + ); + } +}