Skip to content

Commit

Permalink
Added property name in draft-3 required error (#432)
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
sunspikes authored and erayd committed Jun 6, 2017
1 parent 2a42039 commit e53e04c
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 e53e04c

Please sign in to comment.