-
Notifications
You must be signed in to change notification settings - Fork 356
Add missing property name in errors for draft 3 #428
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Same as #91 the property names are missing in errors for draft 3 schema
Well spotted :-). Please change the base branch for this PR to 6.0.0-dev, and use the new error handler. |
@@ -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'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$schema->name
does not exist, and causes test failures.
Noting this is the draft-03 boolean require you have added this for, the property name will not be available via $schema
- you will need to obtain it from elsewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change the base branch for this PR to be 6.0.0-dev.
Changes are no longer being merged directly to master, as we are preparing for the 6.0.0-release. If a change is applicable to 5.x.x (which yours is), then it will be backported after merging to 6.0.0-dev.
@@ -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, 'Is missing and it is required', 'required'); | |||
$propertyName = current($path->getPropertyPaths()); | |||
$this->addError($path, "The property " . $propertyName . " is required", 'required'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per my previous comments, please alter this line to use the new error handler. The syntax you are currently using is deprecated and from 6.0.0 is no longer supported.
Sorry for the confusion, I've created a new PR, I'll close this. Thank you for looking into this! |
Same as #91 the property names are missing in errors for draft 3 schema