Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Add missing property name in errors for draft 3 #428

wants to merge 3 commits into from

Conversation

krishnaprasadmg
Copy link

Same as #91 the property names are missing in errors for draft 3 schema

Same as #91 the property names are missing in errors for draft 3 schema
@erayd
Copy link
Contributor

erayd commented Jun 1, 2017

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');
Copy link
Contributor

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.

Copy link
Contributor

@erayd erayd left a 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');
Copy link
Contributor

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.

@krishnaprasadmg
Copy link
Author

Sorry for the confusion, I've created a new PR, I'll close this. Thank you for looking into this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants