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
  • Loading branch information
sunspikes authored and bighappyface committed Jun 6, 2017
1 parent 5dcbe1d commit 024f3d8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 0 additions & 2 deletions src/JsonSchema/ConstraintError.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class ConstraintError extends Enum
const NOT = 'not';
const ONE_OF = 'oneOf';
const REQUIRED = 'required';
const REQUIRED_D3 = 'selfRequired';
const REQUIRES = 'requires';
const PATTERN = 'pattern';
const PREGEX_INVALID = 'pregrex';
Expand Down Expand Up @@ -93,7 +92,6 @@ public function getMessage()
self::NOT => 'Matched a schema which it should not',
self::ONE_OF => 'Failed to match exactly one schema',
self::REQUIRED => 'The property %s is required',
self::REQUIRED_D3 => 'Is missing and it is required',
self::REQUIRES => 'The presence of the property %s requires that %s also be present',
self::PATTERN => 'Does not match the regex pattern %s',
self::PREGEX_INVALID => 'The pattern %s is invalid',
Expand Down
4 changes: 3 additions & 1 deletion src/JsonSchema/Constraints/UndefinedConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ 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(ConstraintError::REQUIRED_D3(), $path);
$propertyPaths = $path->getPropertyPaths();
$propertyName = end($propertyPaths);
$this->addError(ConstraintError::REQUIRED(), $path, array('property' => $propertyName));
}
}
}
Expand Down

0 comments on commit 024f3d8

Please sign in to comment.