Closed foobargeez closed 7 years ago
That is weird. There's even a test for it: https://github.com/jhthorsen/json-validator/blob/master/t/jv-object.t
The test is failing for both true
and false
for additionalProperties
-- the test seems to be broken.
I dug this a bit ... IIUC, t/Helper.pm
has an issue. If validate()
returns no errors, Test::More::is_deeply
is comparing undef with an array of hashes. I added this line and it seems to evaluate validate_ok
correctly now and is behaving as expected. Please review if it makes sense.
my @errors = validator()->schema($schema)->validate($data);
+ @errors = scalar @errors ? @errors : ({});
Test::More::is_deeply([map { $_->TO_JSON } sort { $a->path cmp $b->path } @errors],
Also, regarding the original issue -- additionalProperties
is not working when set to false
or true
-- per my understanding of code, the module expects this property to be a 0
or 1
and not boolean
. I was setting it to \0
or \1
but the module isn't recognizing it. If you're OK, I am happy to submit a patch that recognizes boolean value for this property and not numeric. Let me know.
For now, I set the value of additionalProperties
in my JSON schema to numeric 0
and I got this working, although, I would ideally prefer to use boolean, so I don't have to diverge the JSON configurations across code bases and programming languages. Let me know your thoughts.
I don't get this at all. 3a3a470d66c093d3a24b9eb4c1fbf3f70cc0e721 shows that your input data is not valid.
Please write a test that shows what you expect.
There seems to be some confusion around $JSON::PP::false
and \0
.
Closing this issue based on the discussion on https://github.com/jhthorsen/json-validator/commit/3a3a470d66c093d3a24b9eb4c1fbf3f70cc0e721
Schema:
input:
JSON::Validator doesn't throw errors (incorrect) while validator at http://www.jsonschemavalidator.net/ throws errors (correct).
Thanks in advance!