From d79f02f633de7da2cbf8570edfc35c6be16e571a Mon Sep 17 00:00:00 2001 From: Percy Hatcherson Date: Sat, 8 Feb 2014 17:49:16 -0600 Subject: [PATCH] Add missing required property names to errors In cases where required properties are missing, the `property` keys in `$this->errors` should contain the names of the missing properties rather than an empty string. This would help a lot for parsing purposes. --- src/JsonSchema/Constraints/Undefined.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonSchema/Constraints/Undefined.php b/src/JsonSchema/Constraints/Undefined.php index ca0800eb..83b8874a 100644 --- a/src/JsonSchema/Constraints/Undefined.php +++ b/src/JsonSchema/Constraints/Undefined.php @@ -121,7 +121,7 @@ protected function validateCommonProperties($value, $schema = null, $path = null // Draft 4 - Required is an array of strings - e.g. "required": ["foo", ...] foreach ($schema->required as $required) { if (!property_exists($value, $required)) { - $this->addError($path, "the property " . $required . " is required"); + $this->addError($required, "required field"); } } } else if (isset($schema->required)) {