Skip to content

Commit cdaf685

Browse files
committed
fix failing 'required' testcase
1 parent 8d5443e commit cdaf685

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/JsonSchema/Constraints/Undefined.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,12 @@ protected function validateCommonProperties($value, $schema = null, $path = null
115115
$this->addError($path, "is missing and it is required");
116116
}
117117
} else if (isset($schema->required)) {
118-
// Draft 4 - Required is an array of strings - e.g. "required": ["foo", ...]
119-
foreach ($schema->required as $required) {
120-
if (!property_exists($value, $required)) {
121-
$this->addError($path, "the property " . $required . " is required");
118+
if( is_array($schema->required)) {
119+
// Draft 4 - Required is an array of strings - e.g. "required": ["foo", ...]
120+
foreach ($schema->required as $required) {
121+
if (!property_exists($value, $required)) {
122+
$this->addError($path, "the property " . $required . " is required");
123+
}
122124
}
123125
}
124126
} else {

0 commit comments

Comments
 (0)