-
-
Notifications
You must be signed in to change notification settings - Fork 296
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
Clarify that adjacent keywords evaluate as if by "allOf" #896
Comments
It's implicit, but I suppose it could be made more explicit in a few places. The spec does say that an empty schema validates to true, and when defining each keyword, it says something like "the keyword has no effect when it is absent", and "the instance successfully validates against the keyword when ..." or "the instance does not successfully validate against the keyword when ...". Also "JSON Schema implementations produce a single boolean result when evaluating an instance against schema assertions." (https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.7.6) -- This section could possibly add something like: "...that means that when multiple keywords apply to the instance at a particular schema location, the single boolean result is the result of ANDing all the individual assertions together." |
I would argue that it's not implicit what to do with the keyword results. Here's why: In the paragraph containing quoted parts about keywords ("The spec does say..."), it effectively states that "each keyword results in a Boolean value when evaluated against an instance." i.e. a successful validation produces "true" and an unsuccessful one produces "false". We also start with a value of "true" when there's an empty schema. So now, given a collection of evaluated keywords, we have a resulting set of Boolean values. Next, there is "JSON Schema implementations produce a single boolean result". This means, as an implementor, I have to somehow combine a collection of Boolean values into a single Boolean result. This is where I feel there's no such implicit step. How to transform a set of Boolean values into a single Boolean value? Now, it doesn't say (or at least I haven't found where) that all keywords must successfully validate in order for a schema to successfully validate. If it did, that would indeed imply a logical AND. I think your suggested addition is necessary to link "collection of Boolean values" with "single Boolean result." We could additionally add some statement to the effect of, "All keywords must successfully validate in order for the schema to successfully validate." Or: "A schema validates if and only if all keywords successfully validate." (To use the mathematical strong bidirectional "if".) |
Yeah we should do this. It was supposed to be part of #849 (which expanded to cover both loading and processing of schemas), but that issue is probably too ambitious for the next draft and we should cover this one key bit. |
Looking at this again, it IS covered by the validation spec document already, although not with any requirement level keywords...
https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.3 This hasn't changed in roughly 3 years. Is the above not enough? |
Yes, I guess that sentence is enough. :) |
It doesn't seem clear in the spec that a schema evaluates to
true
if all its keywords also evaluate totrue
. i.e. anallOf
behaviour.The text was updated successfully, but these errors were encountered: