Closed karenetheridge closed 4 years ago
The values of if/then/else are schemas. The schemas are then applied to the instance location and evaluated. then
or else
schema is applied depending on the validation result of the if
value schema.
@Relequestual Yup, that's how we're treating it, in https://github.com/mojolicious/json-validator/blob/master/lib/JSON/Validator.pm#L871-L876 -- it's a simple matter of adding that check to the other type validator subs as well (or actually, move that check outside of the object sub into the generic _validate sub, to run after the type-specific checks).
(fixed in a branch, not yet PR'd.)
Fixed by #197.
At present, the keywords if, then and else can only be used within the 'object' type. This was probably done because the documentation example (https://json-schema.org/understanding-json-schema/reference/conditionals.html) uses objects, but it should not be limited to that type.
These keywords are described in the specification at https://tools.ietf.org/html/draft-handrews-json-schema-validation-01#section-6.6.