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
fix if-then-else, anyOf, dependencies #197
fix if-then-else, anyOf, dependencies #197
Conversation
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.
I have a hard time accepting this PR, since there's so many unrelated changes bundled into one PR. I wish it was split into three PR's. Either way, I want to merge it 👍
Please review my comments.
push @errors, | ||
$self->_validate_any_of($to_json ? $$to_json : $_[1], $path, $rules); | ||
} | ||
elsif ($rules = $schema->{oneOf}) { | ||
|
||
if (my $rules = $schema->{oneOf}) { |
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.
Side note: I really hope nobody actually uses this. Seems like a too complicated schema to understand.
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.
a combination of oneOf, anyOf and allOf all at the same time? hey, you never know :D
push @errors, | ||
$self->_validate_one_of($to_json ? $$to_json : $_[1], $path, $rules); | ||
} | ||
|
||
if ($schema->{if}) { |
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.
👍
063dce5
to
3c314d9
Compare
lib/JSON/Validator/Error.pm
Outdated
@@ -35,6 +35,7 @@ our $MESSAGES = { | |||
maxProperties => 'Too many properties: %3/%4.', | |||
minProperties => 'Not enough properties: %3/%4.', | |||
required => 'Missing property.', | |||
dependencies => 'Missing property: Dependee: %3.', |
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.
Too many colons. How about "Missing property. Dependee: %3."
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.
fixed.
8b5ab16
to
e759a15
Compare
e759a15
to
8ea23ad
Compare
Awesome 👍 |
Summary
fixes bugs: #190, #196, #192 where various keywords were not fully supported
Motivation
see their respective issues for background and references
I am not quite sure what error messages are best: "Missing property" was already being used by the 'required' keyword, and it's not great to have two different errors sharing the same message, so I made the 'required' error "Missing required property", so 'dependencies' can have "Missing dependent property". However, changing an existing error message might break unit tests in downstream code.