diff --git a/hyper-schema.json b/hyper-schema.json index 484af6c5..74c6bec7 100644 --- a/hyper-schema.json +++ b/hyper-schema.json @@ -4,6 +4,7 @@ "$vocabulary": { "https://json-schema.org/draft/2019-09/vocab/core": true, "https://json-schema.org/draft/2019-09/vocab/applicator": true, + "https://json-schema.org/draft/2019-09/vocab/unevaluated": true, "https://json-schema.org/draft/2019-09/vocab/validation": true, "https://json-schema.org/draft/2019-09/vocab/meta-data": true, "https://json-schema.org/draft/2019-09/vocab/format": false, diff --git a/jsonschema-core.xml b/jsonschema-core.xml index 1c2ac6c4..3dbc7ea5 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -336,6 +336,9 @@ results. They should not define additional constraints independent of their subschemas. + + Keywords within the same schema object are referred to as adjacent keywords. + Extension keywords, meaning those defined outside of this document and its companions, are free to define other behaviors as well. @@ -674,7 +677,8 @@
Keyword behavior MAY be defined in terms of the annotation results - of subschemas and/or adjacent keywords. + of subschemas and/or adjacent keywords + (keywords within the same schema object) and their subschemas. Such keywords MUST NOT result in a circular dependency. Keywords MAY modify their behavior based on the presence or absence of another keyword in the same @@ -700,15 +704,18 @@ Because annotation collection can add significant cost in terms of both computation and memory, implementations MAY opt out of this feature. - Keywords known to an implementation to have assertion or applicator behavior - that depend on annotation results MUST then be treated as errors, unless - an alternate implementation producing the same behavior is available. - Keywords of this sort SHOULD describe reasonable alternate approaches - when appropriate. This approach is demonstrated by the + Keywords that are specified in terms of collected annotations SHOULD + describe reasonable alternate approaches when appropriate. + This approach is demonstrated by the "" and "" keywords in this document. + + Note that when no such alternate approach is possible for a keyword, + implementations that do not support annotation collections will not + be able to support those keywords or vocabularies that contain them. +
@@ -2346,52 +2353,6 @@
-
- - The value of "unevaluatedItems" MUST be a valid JSON Schema. - - - The behavior of this keyword depends on the annotation results of - adjacent keywords that apply to the instance location being validated. - Specifically, the annotations from "prefixItems", "items", and "contains", - which can come from those keywords when they are adjacent to the - "unevaluatedItems" keyword. Those two annotations, as well as - "unevaluatedItems", can also result from any and all adjacent - in-place applicator keywords. - This includes but is not limited to the in-place applicators - defined in this document. - - - If no relevant annotations are present, the "unevaluatedItems" - subschema MUST be applied to all locations in the array. - If a boolean true value is present from any of the relevant annotations, - "unevaluatedItems" MUST be ignored. Otherwise, the subschema - MUST be applied to any index greater than the largest annotation - value for "prefixItems", which does not appear in any annotation - value for "contains". - - - This means that "prefixItems", "items", "contains", and all in-place - applicators MUST be evaluated before this keyword can be evaluated. - Authors of extension keywords MUST NOT define an in-place applicator - that would need to be evaluated before this keyword. - - - If the "unevaluatedItems" subschema is applied to any - positions within the instance array, it produces an - annotation result of boolean true, analogous to the - behavior of "items". - - - Omitting this keyword has the same assertion behavior as - an empty schema. - - - Implementations that do not collect annotations MUST raise an error - upon encountering this keyword. - -
-
The value of this keyword MUST be a valid JSON Schema. @@ -2499,56 +2460,6 @@
-
- - The value of "unevaluatedProperties" MUST be a valid JSON Schema. - - - The behavior of this keyword depends on the annotation results of - adjacent keywords that apply to the instance location being validated. - Specifically, the annotations from "properties", "patternProperties", - and "additionalProperties", which can come from those keywords when - they are adjacent to the "unevaluatedProperties" keyword. Those - three annotations, as well as "unevaluatedProperties", can also - result from any and all adjacent - in-place applicator keywords. - This includes but is not limited to the in-place applicators - defined in this document. - - - Validation with "unevaluatedProperties" applies only to the child - values of instance names that do not appear in the "properties", - "patternProperties", "additionalProperties", or - "unevaluatedProperties" annotation results that apply to the - instance location being validated. - - - For all such properties, validation succeeds if the child instance - validates against the "unevaluatedProperties" schema. - - - This means that "properties", "patternProperties", "additionalProperties", - and all in-place applicators MUST be evaluated before this keyword can - be evaluated. Authors of extension keywords MUST NOT define an in-place - applicator that would need to be evaluated before this keyword. - - - The annotation result of this keyword is the set of instance - property names validated by this keyword's subschema. - Annotation results for "unevaluatedProperties" keywords from - multiple schemas applied to the same instance location are combined - by taking the union of the sets. - - - Omitting this keyword has the same assertion behavior as - an empty schema. - - - Implementations that do not collect annotations MUST raise an error - upon encountering this keyword. - -
-
The value of "propertyNames" MUST be a valid JSON Schema. @@ -2566,6 +2477,138 @@
+
+ + The purpose of these keywords is to enable schema authors to apply + subschemas to array items or object properties that have not been + successfully evaluated against any dynamic-scope subschema of any + adjacent keywords. + + + These instance items or properties may have been unsuccessfully evaluated + against one or more adjacent keyword subschemas, such as when an assertion + in a branch of an "anyOf" fails. Such failed evaluations are not considered + to contribute to whether or not the item or property has been evaluated. + Only successful evaluations are considered. + + + Recall that adjacent keywords are keywords within the same schema object, + and that the dynamic-scope subschemas include reference targets as well as + lexical subschemas. + + + The behavior of these keywords depend on the annotation results of + adjacent keywords that apply to the instance location being validated. + + + Meta-schemas that do not use "$vocabulary" SHOULD be considered to + require this vocabulary as if its URI were present with a value of true. + + + The current URI for this vocabulary, known as the Unevaluated Applicator + vocabulary, is: + <https://json-schema.org/draft/2019-09/vocab/unevaluated>. + + + The current URI for the corresponding meta-schema is: + . + + + Updated vocabulary and meta-schema URIs MAY be published between + specification drafts in order to correct errors. Implementations + SHOULD consider URIs dated after this specification draft and + before the next to indicate the same syntax and semantics + as those listed here. + +
+ + The value of "unevaluatedItems" MUST be a valid JSON Schema. + + + The behavior of this keyword depends on the annotation results of + adjacent keywords that apply to the instance location being validated. + Specifically, the annotations from "prefixItems", "items", and "contains", + which can come from those keywords when they are adjacent to the + "unevaluatedItems" keyword. Those two annotations, as well as + "unevaluatedItems", can also result from any and all adjacent + in-place applicator keywords. + This includes but is not limited to the in-place applicators + defined in this document. + + + If no relevant annotations are present, the "unevaluatedItems" + subschema MUST be applied to all locations in the array. + If a boolean true value is present from any of the relevant annotations, + "unevaluatedItems" MUST be ignored. Otherwise, the subschema + MUST be applied to any index greater than the largest annotation + value for "prefixItems", which does not appear in any annotation + value for "contains". + + + This means that "prefixItems", "items", "contains", and all in-place + applicators MUST be evaluated before this keyword can be evaluated. + Authors of extension keywords MUST NOT define an in-place applicator + that would need to be evaluated before this keyword. + + + If the "unevaluatedItems" subschema is applied to any + positions within the instance array, it produces an + annotation result of boolean true, analogous to the + behavior of "items". + + + Omitting this keyword has the same assertion behavior as + an empty schema. + +
+ +
+ + The value of "unevaluatedProperties" MUST be a valid JSON Schema. + + + The behavior of this keyword depends on the annotation results of + adjacent keywords that apply to the instance location being validated. + Specifically, the annotations from "properties", "patternProperties", + and "additionalProperties", which can come from those keywords when + they are adjacent to the "unevaluatedProperties" keyword. Those + three annotations, as well as "unevaluatedProperties", can also + result from any and all adjacent + in-place applicator keywords. + This includes but is not limited to the in-place applicators + defined in this document. + + + Validation with "unevaluatedProperties" applies only to the child + values of instance names that do not appear in the "properties", + "patternProperties", "additionalProperties", or + "unevaluatedProperties" annotation results that apply to the + instance location being validated. + + + For all such properties, validation succeeds if the child instance + validates against the "unevaluatedProperties" schema. + + + This means that "properties", "patternProperties", "additionalProperties", + and all in-place applicators MUST be evaluated before this keyword can + be evaluated. Authors of extension keywords MUST NOT define an in-place + applicator that would need to be evaluated before this keyword. + + + The annotation result of this keyword is the set of instance + property names validated by this keyword's subschema. + Annotation results for "unevaluatedProperties" keywords from + multiple schemas applied to the same instance location are combined + by taking the union of the sets. + + + Omitting this keyword has the same assertion behavior as + an empty schema. + +
+
+
JSON Schema is defined to be platform-independent. As such, to increase compatibility diff --git a/meta/applicator.json b/meta/applicator.json index 64af5792..019fb3a1 100644 --- a/meta/applicator.json +++ b/meta/applicator.json @@ -11,10 +11,8 @@ "properties": { "prefixItems": { "$ref": "#/$defs/schemaArray" }, "items": { "$dynamicRef": "#meta" }, - "unevaluatedItems": { "$dynamicRef": "#meta" }, "contains": { "$dynamicRef": "#meta" }, "additionalProperties": { "$dynamicRef": "#meta" }, - "unevaluatedProperties": { "$dynamicRef": "#meta" }, "properties": { "type": "object", "additionalProperties": { "$dynamicRef": "#meta" }, diff --git a/meta/unevaluated.json b/meta/unevaluated.json new file mode 100644 index 00000000..e973bd29 --- /dev/null +++ b/meta/unevaluated.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "$id": "https://json-schema.org/draft/2019-09/meta/unevaluated", + "$vocabulary": { + "https://json-schema.org/draft/2019-09/vocab/unevaluated": true + }, + "$dynamicAnchor": "meta", + + "title": "Unevaluated applicator vocabulary meta-schema", + "type": ["object", "boolean"], + "properties": { + "unevaluatedItems": { "$dynamicRef": "#meta" }, + "unevaluatedProperties": { "$dynamicRef": "#meta" } + } +} diff --git a/schema.json b/schema.json index 4d4e8782..0544997c 100644 --- a/schema.json +++ b/schema.json @@ -4,6 +4,7 @@ "$vocabulary": { "https://json-schema.org/draft/2019-09/vocab/core": true, "https://json-schema.org/draft/2019-09/vocab/applicator": true, + "https://json-schema.org/draft/2019-09/vocab/unevaluated": true, "https://json-schema.org/draft/2019-09/vocab/validation": true, "https://json-schema.org/draft/2019-09/vocab/meta-data": true, "https://json-schema.org/draft/2019-09/vocab/format": false,