Skip to content

Commit cba93cb

Browse files
authored
Merge pull request #981 from handrews/uneval
Split "unevaluatedItems" and "unevaluatedProperties" into their own vocabulary.
2 parents f10a9e3 + 336789f commit cba93cb

File tree

5 files changed

+162
-104
lines changed

5 files changed

+162
-104
lines changed

hyper-schema.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"$vocabulary": {
55
"https://json-schema.org/draft/2019-09/vocab/core": true,
66
"https://json-schema.org/draft/2019-09/vocab/applicator": true,
7+
"https://json-schema.org/draft/2019-09/vocab/unevaluated": true,
78
"https://json-schema.org/draft/2019-09/vocab/validation": true,
89
"https://json-schema.org/draft/2019-09/vocab/meta-data": true,
910
"https://json-schema.org/draft/2019-09/vocab/format": false,

jsonschema-core.xml

+145-102
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,9 @@
342342
results. They should not define additional constraints independent
343343
of their subschemas.
344344
</t>
345+
<t>
346+
Keywords within the same schema object are referred to as adjacent keywords.
347+
</t>
345348
<t>
346349
Extension keywords, meaning those defined outside of this document
347350
and its companions, are free to define other behaviors as well.
@@ -680,7 +683,8 @@
680683
<section title="Keyword Interactions">
681684
<t>
682685
Keyword behavior MAY be defined in terms of the annotation results
683-
of <xref target="root">subschemas</xref> and/or adjacent keywords.
686+
of <xref target="root">subschemas</xref> and/or adjacent keywords
687+
(keywords within the same schema object) and their subschemas.
684688
Such keywords MUST NOT result in a circular dependency.
685689
Keywords MAY modify their behavior based on the presence or absence
686690
of another keyword in the same
@@ -706,15 +710,18 @@
706710
<t>
707711
Because annotation collection can add significant cost in terms of both
708712
computation and memory, implementations MAY opt out of this feature.
709-
Keywords known to an implementation to have assertion or applicator behavior
710-
that depend on annotation results MUST then be treated as errors, unless
711-
an alternate implementation producing the same behavior is available.
712-
Keywords of this sort SHOULD describe reasonable alternate approaches
713-
when appropriate. This approach is demonstrated by the
713+
Keywords that are specified in terms of collected annotations SHOULD
714+
describe reasonable alternate approaches when appropriate.
715+
This approach is demonstrated by the
714716
"<xref target="items" format="title"/>" and
715717
"<xref target="additionalProperties" format="title"/>" keywords in this
716718
document.
717719
</t>
720+
<t>
721+
Note that when no such alternate approach is possible for a keyword,
722+
implementations that do not support annotation collections will not
723+
be able to support those keywords or vocabularies that contain them.
724+
</t>
718725
</section>
719726
<section title="Identifiers" anchor="identifiers">
720727
<t>
@@ -2357,52 +2364,6 @@
23572364
</t>
23582365
</section>
23592366

2360-
<section title="unevaluatedItems" anchor="unevaluatedItems">
2361-
<t>
2362-
The value of "unevaluatedItems" MUST be a valid JSON Schema.
2363-
</t>
2364-
<t>
2365-
The behavior of this keyword depends on the annotation results of
2366-
adjacent keywords that apply to the instance location being validated.
2367-
Specifically, the annotations from "prefixItems", "items", and "contains",
2368-
which can come from those keywords when they are adjacent to the
2369-
"unevaluatedItems" keyword. Those two annotations, as well as
2370-
"unevaluatedItems", can also result from any and all adjacent
2371-
<xref target="in-place">in-place applicator</xref> keywords.
2372-
This includes but is not limited to the in-place applicators
2373-
defined in this document.
2374-
</t>
2375-
<t>
2376-
If no relevant annotations are present, the "unevaluatedItems"
2377-
subschema MUST be applied to all locations in the array.
2378-
If a boolean true value is present from any of the relevant annotations,
2379-
"unevaluatedItems" MUST be ignored. Otherwise, the subschema
2380-
MUST be applied to any index greater than the largest annotation
2381-
value for "prefixItems", which does not appear in any annotation
2382-
value for "contains".
2383-
</t>
2384-
<t>
2385-
This means that "prefixItems", "items", "contains", and all in-place
2386-
applicators MUST be evaluated before this keyword can be evaluated.
2387-
Authors of extension keywords MUST NOT define an in-place applicator
2388-
that would need to be evaluated before this keyword.
2389-
</t>
2390-
<t>
2391-
If the "unevaluatedItems" subschema is applied to any
2392-
positions within the instance array, it produces an
2393-
annotation result of boolean true, analogous to the
2394-
behavior of "items".
2395-
</t>
2396-
<t>
2397-
Omitting this keyword has the same assertion behavior as
2398-
an empty schema.
2399-
</t>
2400-
<t>
2401-
Implementations that do not collect annotations MUST raise an error
2402-
upon encountering this keyword.
2403-
</t>
2404-
</section>
2405-
24062367
<section title="contains">
24072368
<t>
24082369
The value of this keyword MUST be a valid JSON Schema.
@@ -2510,56 +2471,6 @@
25102471
</t>
25112472
</section>
25122473

2513-
<section title="unevaluatedProperties" anchor="unevaluatedProperties">
2514-
<t>
2515-
The value of "unevaluatedProperties" MUST be a valid JSON Schema.
2516-
</t>
2517-
<t>
2518-
The behavior of this keyword depends on the annotation results of
2519-
adjacent keywords that apply to the instance location being validated.
2520-
Specifically, the annotations from "properties", "patternProperties",
2521-
and "additionalProperties", which can come from those keywords when
2522-
they are adjacent to the "unevaluatedProperties" keyword. Those
2523-
three annotations, as well as "unevaluatedProperties", can also
2524-
result from any and all adjacent
2525-
<xref target="in-place">in-place applicator</xref> keywords.
2526-
This includes but is not limited to the in-place applicators
2527-
defined in this document.
2528-
</t>
2529-
<t>
2530-
Validation with "unevaluatedProperties" applies only to the child
2531-
values of instance names that do not appear in the "properties",
2532-
"patternProperties", "additionalProperties", or
2533-
"unevaluatedProperties" annotation results that apply to the
2534-
instance location being validated.
2535-
</t>
2536-
<t>
2537-
For all such properties, validation succeeds if the child instance
2538-
validates against the "unevaluatedProperties" schema.
2539-
</t>
2540-
<t>
2541-
This means that "properties", "patternProperties", "additionalProperties",
2542-
and all in-place applicators MUST be evaluated before this keyword can
2543-
be evaluated. Authors of extension keywords MUST NOT define an in-place
2544-
applicator that would need to be evaluated before this keyword.
2545-
</t>
2546-
<t>
2547-
The annotation result of this keyword is the set of instance
2548-
property names validated by this keyword's subschema.
2549-
Annotation results for "unevaluatedProperties" keywords from
2550-
multiple schemas applied to the same instance location are combined
2551-
by taking the union of the sets.
2552-
</t>
2553-
<t>
2554-
Omitting this keyword has the same assertion behavior as
2555-
an empty schema.
2556-
</t>
2557-
<t>
2558-
Implementations that do not collect annotations MUST raise an error
2559-
upon encountering this keyword.
2560-
</t>
2561-
</section>
2562-
25632474
<section title="propertyNames">
25642475
<t>
25652476
The value of "propertyNames" MUST be a valid JSON Schema.
@@ -2577,6 +2488,138 @@
25772488
</section>
25782489
</section>
25792490

2491+
<section title="A Vocabulary for Unevaluated Locations">
2492+
<t>
2493+
The purpose of these keywords is to enable schema authors to apply
2494+
subschemas to array items or object properties that have not been
2495+
successfully evaluated against any dynamic-scope subschema of any
2496+
adjacent keywords.
2497+
</t>
2498+
<t>
2499+
These instance items or properties may have been unsuccessfully evaluated
2500+
against one or more adjacent keyword subschemas, such as when an assertion
2501+
in a branch of an "anyOf" fails. Such failed evaluations are not considered
2502+
to contribute to whether or not the item or property has been evaluated.
2503+
Only successful evaluations are considered.
2504+
</t>
2505+
<t>
2506+
Recall that adjacent keywords are keywords within the same schema object,
2507+
and that the dynamic-scope subschemas include reference targets as well as
2508+
lexical subschemas.
2509+
</t>
2510+
<t>
2511+
The behavior of these keywords depend on the annotation results of
2512+
adjacent keywords that apply to the instance location being validated.
2513+
</t>
2514+
<t>
2515+
Meta-schemas that do not use "$vocabulary" SHOULD be considered to
2516+
require this vocabulary as if its URI were present with a value of true.
2517+
</t>
2518+
<t>
2519+
The current URI for this vocabulary, known as the Unevaluated Applicator
2520+
vocabulary, is:
2521+
&lt;https://json-schema.org/draft/2019-09/vocab/unevaluated&gt;.
2522+
</t>
2523+
<t>
2524+
The current URI for the corresponding meta-schema is:
2525+
<eref target="https://json-schema.org/draft/2019-09/meta/unevaluated"/>.
2526+
</t>
2527+
<t>
2528+
Updated vocabulary and meta-schema URIs MAY be published between
2529+
specification drafts in order to correct errors. Implementations
2530+
SHOULD consider URIs dated after this specification draft and
2531+
before the next to indicate the same syntax and semantics
2532+
as those listed here.
2533+
</t>
2534+
<section title="unevaluatedItems" anchor="unevaluatedItems">
2535+
<t>
2536+
The value of "unevaluatedItems" MUST be a valid JSON Schema.
2537+
</t>
2538+
<t>
2539+
The behavior of this keyword depends on the annotation results of
2540+
adjacent keywords that apply to the instance location being validated.
2541+
Specifically, the annotations from "prefixItems", "items", and "contains",
2542+
which can come from those keywords when they are adjacent to the
2543+
"unevaluatedItems" keyword. Those two annotations, as well as
2544+
"unevaluatedItems", can also result from any and all adjacent
2545+
<xref target="in-place">in-place applicator</xref> keywords.
2546+
This includes but is not limited to the in-place applicators
2547+
defined in this document.
2548+
</t>
2549+
<t>
2550+
If no relevant annotations are present, the "unevaluatedItems"
2551+
subschema MUST be applied to all locations in the array.
2552+
If a boolean true value is present from any of the relevant annotations,
2553+
"unevaluatedItems" MUST be ignored. Otherwise, the subschema
2554+
MUST be applied to any index greater than the largest annotation
2555+
value for "prefixItems", which does not appear in any annotation
2556+
value for "contains".
2557+
</t>
2558+
<t>
2559+
This means that "prefixItems", "items", "contains", and all in-place
2560+
applicators MUST be evaluated before this keyword can be evaluated.
2561+
Authors of extension keywords MUST NOT define an in-place applicator
2562+
that would need to be evaluated before this keyword.
2563+
</t>
2564+
<t>
2565+
If the "unevaluatedItems" subschema is applied to any
2566+
positions within the instance array, it produces an
2567+
annotation result of boolean true, analogous to the
2568+
behavior of "items".
2569+
</t>
2570+
<t>
2571+
Omitting this keyword has the same assertion behavior as
2572+
an empty schema.
2573+
</t>
2574+
</section>
2575+
2576+
<section title="unevaluatedProperties" anchor="unevaluatedProperties">
2577+
<t>
2578+
The value of "unevaluatedProperties" MUST be a valid JSON Schema.
2579+
</t>
2580+
<t>
2581+
The behavior of this keyword depends on the annotation results of
2582+
adjacent keywords that apply to the instance location being validated.
2583+
Specifically, the annotations from "properties", "patternProperties",
2584+
and "additionalProperties", which can come from those keywords when
2585+
they are adjacent to the "unevaluatedProperties" keyword. Those
2586+
three annotations, as well as "unevaluatedProperties", can also
2587+
result from any and all adjacent
2588+
<xref target="in-place">in-place applicator</xref> keywords.
2589+
This includes but is not limited to the in-place applicators
2590+
defined in this document.
2591+
</t>
2592+
<t>
2593+
Validation with "unevaluatedProperties" applies only to the child
2594+
values of instance names that do not appear in the "properties",
2595+
"patternProperties", "additionalProperties", or
2596+
"unevaluatedProperties" annotation results that apply to the
2597+
instance location being validated.
2598+
</t>
2599+
<t>
2600+
For all such properties, validation succeeds if the child instance
2601+
validates against the "unevaluatedProperties" schema.
2602+
</t>
2603+
<t>
2604+
This means that "properties", "patternProperties", "additionalProperties",
2605+
and all in-place applicators MUST be evaluated before this keyword can
2606+
be evaluated. Authors of extension keywords MUST NOT define an in-place
2607+
applicator that would need to be evaluated before this keyword.
2608+
</t>
2609+
<t>
2610+
The annotation result of this keyword is the set of instance
2611+
property names validated by this keyword's subschema.
2612+
Annotation results for "unevaluatedProperties" keywords from
2613+
multiple schemas applied to the same instance location are combined
2614+
by taking the union of the sets.
2615+
</t>
2616+
<t>
2617+
Omitting this keyword has the same assertion behavior as
2618+
an empty schema.
2619+
</t>
2620+
</section>
2621+
</section>
2622+
25802623
<section title="Output Formatting" anchor="output">
25812624
<t>
25822625
JSON Schema is defined to be platform-independent. As such, to increase compatibility

meta/applicator.json

-2
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@
1111
"properties": {
1212
"prefixItems": { "$ref": "#/$defs/schemaArray" },
1313
"items": { "$dynamicRef": "#meta" },
14-
"unevaluatedItems": { "$dynamicRef": "#meta" },
1514
"contains": { "$dynamicRef": "#meta" },
1615
"additionalProperties": { "$dynamicRef": "#meta" },
17-
"unevaluatedProperties": { "$dynamicRef": "#meta" },
1816
"properties": {
1917
"type": "object",
2018
"additionalProperties": { "$dynamicRef": "#meta" },

meta/unevaluated.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2019-09/schema",
3+
"$id": "https://json-schema.org/draft/2019-09/meta/unevaluated",
4+
"$vocabulary": {
5+
"https://json-schema.org/draft/2019-09/vocab/unevaluated": true
6+
},
7+
"$dynamicAnchor": "meta",
8+
9+
"title": "Unevaluated applicator vocabulary meta-schema",
10+
"type": ["object", "boolean"],
11+
"properties": {
12+
"unevaluatedItems": { "$dynamicRef": "#meta" },
13+
"unevaluatedProperties": { "$dynamicRef": "#meta" }
14+
}
15+
}

schema.json

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"$vocabulary": {
55
"https://json-schema.org/draft/2019-09/vocab/core": true,
66
"https://json-schema.org/draft/2019-09/vocab/applicator": true,
7+
"https://json-schema.org/draft/2019-09/vocab/unevaluated": true,
78
"https://json-schema.org/draft/2019-09/vocab/validation": true,
89
"https://json-schema.org/draft/2019-09/vocab/meta-data": true,
910
"https://json-schema.org/draft/2019-09/vocab/format": false,

0 commit comments

Comments
 (0)