Skip to content

Commit 024f3d8

Browse files
sunspikesbighappyface
authored andcommitted
Added property name in draft-3 required error (#432)
1 parent 5dcbe1d commit 024f3d8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/JsonSchema/ConstraintError.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class ConstraintError extends Enum
4343
const NOT = 'not';
4444
const ONE_OF = 'oneOf';
4545
const REQUIRED = 'required';
46-
const REQUIRED_D3 = 'selfRequired';
4746
const REQUIRES = 'requires';
4847
const PATTERN = 'pattern';
4948
const PREGEX_INVALID = 'pregrex';
@@ -93,7 +92,6 @@ public function getMessage()
9392
self::NOT => 'Matched a schema which it should not',
9493
self::ONE_OF => 'Failed to match exactly one schema',
9594
self::REQUIRED => 'The property %s is required',
96-
self::REQUIRED_D3 => 'Is missing and it is required',
9795
self::REQUIRES => 'The presence of the property %s requires that %s also be present',
9896
self::PATTERN => 'Does not match the regex pattern %s',
9997
self::PREGEX_INVALID => 'The pattern %s is invalid',

src/JsonSchema/Constraints/UndefinedConstraint.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ protected function validateCommonProperties(&$value, $schema = null, JsonPointer
144144
} elseif (isset($schema->required) && !is_array($schema->required)) {
145145
// Draft 3 - Required attribute - e.g. "foo": {"type": "string", "required": true}
146146
if ($schema->required && $value instanceof self) {
147-
$this->addError(ConstraintError::REQUIRED_D3(), $path);
147+
$propertyPaths = $path->getPropertyPaths();
148+
$propertyName = end($propertyPaths);
149+
$this->addError(ConstraintError::REQUIRED(), $path, array('property' => $propertyName));
148150
}
149151
}
150152
}

0 commit comments

Comments
 (0)