Skip to content

Commit

Permalink
Added property name in draft-3 required error (#432) (#433)
Browse files Browse the repository at this point in the history
Backport modifications:
 * Change error syntax to use the old pre-6.0.0 API
  • Loading branch information
erayd authored and bighappyface committed Jun 23, 2017
1 parent 2a42039 commit 36ed4d9
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/JsonSchema/Constraints/UndefinedConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,13 @@ protected function validateCommonProperties(&$value, $schema = null, JsonPointer
} elseif (isset($schema->required) && !is_array($schema->required)) {
// Draft 3 - Required attribute - e.g. "foo": {"type": "string", "required": true}
if ($schema->required && $value instanceof self) {
$this->addError($path, 'Is missing and it is required', 'required');
$propertyPaths = $path->getPropertyPaths();
$propertyName = end($propertyPaths);
$this->addError(
$path,
'The property ' . $propertyName . ' is required',
'required'
);
}
}
}
Expand Down

0 comments on commit 36ed4d9

Please sign in to comment.