Skip to content

Commit 16ad7dd

Browse files
sunspikeserayd
authored andcommitted
Added property name in draft-3 required error (jsonrainbow#432)
Backport modifications: * Change error syntax to use pre-6.0.0 API
1 parent 2a42039 commit 16ad7dd

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/JsonSchema/Constraints/UndefinedConstraint.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,13 @@ protected function validateCommonProperties(&$value, $schema = null, JsonPointer
142142
} elseif (isset($schema->required) && !is_array($schema->required)) {
143143
// Draft 3 - Required attribute - e.g. "foo": {"type": "string", "required": true}
144144
if ($schema->required && $value instanceof self) {
145-
$this->addError($path, 'Is missing and it is required', 'required');
145+
$propertyPaths = $path->getPropertyPaths();
146+
$propertyName = end($propertyPaths);
147+
$this->addError(
148+
$this->incrementPath($path ?: new JsonPointer(''), $propertyName),
149+
'The property ' . $propertyName . ' is required',
150+
'required'
151+
);
146152
}
147153
}
148154
}

0 commit comments

Comments
 (0)