From e37d414ee6252115dd9941ff8a0eea6987844fd5 Mon Sep 17 00:00:00 2001 From: Krishnaprasad MG Date: Thu, 1 Jun 2017 18:01:47 +0200 Subject: [PATCH 1/3] Add missing property name in errors for draft 3 Same as #91 the property names are missing in errors for draft 3 schema --- src/JsonSchema/Constraints/UndefinedConstraint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/JsonSchema/Constraints/UndefinedConstraint.php b/src/JsonSchema/Constraints/UndefinedConstraint.php index 147e5bc3..0bbe7ab4 100644 --- a/src/JsonSchema/Constraints/UndefinedConstraint.php +++ b/src/JsonSchema/Constraints/UndefinedConstraint.php @@ -169,7 +169,7 @@ 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'); + $this->addError($path, "The property " . $schema->name . " is required", 'required'); } } } From d97058400ddbb92de6e98f35cbfac1cc16355474 Mon Sep 17 00:00:00 2001 From: Krishnaprasad MG Date: Fri, 2 Jun 2017 11:13:15 +0200 Subject: [PATCH 2/3] Update UndefinedConstraint.php --- src/JsonSchema/Constraints/UndefinedConstraint.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/JsonSchema/Constraints/UndefinedConstraint.php b/src/JsonSchema/Constraints/UndefinedConstraint.php index 0bbe7ab4..47890e23 100644 --- a/src/JsonSchema/Constraints/UndefinedConstraint.php +++ b/src/JsonSchema/Constraints/UndefinedConstraint.php @@ -169,7 +169,8 @@ 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, "The property " . $schema->name . " is required", 'required'); + $schemaName = current($path->getPropertyPaths()); + $this->addError($path, "The property " . $schemaName . " is required", 'required'); } } } From 48ff41cfa8ff786a50d9ad8918670afe67322ac7 Mon Sep 17 00:00:00 2001 From: Krishnaprasad MG Date: Fri, 2 Jun 2017 11:17:44 +0200 Subject: [PATCH 3/3] Update UndefinedConstraint.php --- src/JsonSchema/Constraints/UndefinedConstraint.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JsonSchema/Constraints/UndefinedConstraint.php b/src/JsonSchema/Constraints/UndefinedConstraint.php index 47890e23..eb830823 100644 --- a/src/JsonSchema/Constraints/UndefinedConstraint.php +++ b/src/JsonSchema/Constraints/UndefinedConstraint.php @@ -169,8 +169,8 @@ 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) { - $schemaName = current($path->getPropertyPaths()); - $this->addError($path, "The property " . $schemaName . " is required", 'required'); + $propertyName = current($path->getPropertyPaths()); + $this->addError($path, "The property " . $propertyName . " is required", 'required'); } } }