Closed DrHyde closed 3 years ago
I don’t see how “Can't call method "req" on an undefined value” is related to this. Also the schema does not reflect the error description.
Please provide a failing test. You can use https://github.com/mojolicious/json-validator/blob/7d89c7e8ad54b5d2eb41530aaa93bfd00a7b20d0/t/jv-object.t#L29 as a template.
Hmmm, I may have cast blame incorrectly as I can't see how that error can possibly be generated. There's definitely something funky going on with additionalProperties, but I'll close the ticket for now and open another if I can boil it down to a small example.
Steps to reproduce the behavior
Given a schema that specifies this object:
ie, which validates that
location
is an object and that thepostcode
,region
, andcountry
fields are optional strings, try to validate this JSON:Expected behavior
No error, because I've not said
"additionalProperties": false
, and the default is supposed to betrue
.Actual behavior
Perl spits an error:
Can't call method "req" on an undefined value ...
NB that if I explicitly set
"additionalProperties": true
then we get the same incorrect behaviour. If I set it tofalse
then I get a sensible error.