Skip to content

Commit a0979f3

Browse files
committed
Futher clarify primitive vs child validation.
A lot of the most confusing language around the "additional" keywords can be removed if we consider keywords strictly with respect to either the instance's primitive type or against child instances. Describing {"additionalItems": false} as failing child validation of elements beyond the length of "items" is more straightforward and has the same effect as the more convoluted reasoning about length.
1 parent a9d2d3b commit a0979f3

File tree

1 file changed

+30
-39
lines changed

1 file changed

+30
-39
lines changed

Diff for: jsonschema-validation.xml

+30-39
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,20 @@
168168
</t>
169169
</section>
170170

171+
<section title="Validation of primitive types and child values">
172+
<t>
173+
Two of the primitive types, array and object, allow for child values. The validation of
174+
the primitive type is considered separately from the validation of child instances.
175+
</t>
176+
<t>
177+
For arrays, primitive type validation consists of validating restrictions on length.
178+
</t>
179+
<t>
180+
For objects, primitive type validation consists of validating restrictions on the presence
181+
or absence of property names.
182+
</t>
183+
</section>
184+
171185
<section title="Missing keywords">
172186
<t>
173187
Validation keywords that are missing never restrict validation.
@@ -306,7 +320,8 @@
306320
If absent, it can be considered present with an empty schema.
307321
</t>
308322
<t>
309-
Validation of this keyword against the instance always succeeds.
323+
This keyword controls child instance validation. Validation of the
324+
primitive instance type against this keyword always succeeds.
310325
</t>
311326
<t>
312327
If "items" is a schema, child validation succeeds if all elements
@@ -328,29 +343,13 @@
328343
If absent, it can be considered present with an empty schema.
329344
</t>
330345
<t>
331-
If "additionalItems" is true or a schema, or if "items"
332-
is absent or a single schema, or if the instance is not
333-
an array, then validation of the instance always succeeds.
334-
</t>
335-
<t>
336-
If "additionalItems" is false, and "items" is an array
337-
of schemas, validation of the instance succeeds if
338-
the size of the instance is less than, or equal to,
339-
the size of "items".
340-
</t>
341-
<t>
342-
Child validation with respect to "additionalItems" only applies
343-
when "items" is an array of schemas, and only applies to
344-
instance elements at positions greater than the size of "items".
345-
</t>
346-
<t>
347-
If "additionalItems" is true, child validation always succeeds.
346+
This keyword controls child instance validation. Validation of the
347+
primitive instance type against this keyword always succeeds.
348348
</t>
349349
<t>
350-
If "additionalItems" is a schema, child validation succeeds
351-
if all instance elements at positions greater than the size
352-
of "items" successfully validate against the "additionalItems"
353-
schema.
350+
If "items" is an array of schemas, child validation succeeds
351+
if every instance element at a position greater than the size
352+
of "items" validates against "additionalItems".
354353
</t>
355354
</section>
356355

@@ -444,7 +443,8 @@
444443
If absent, it can be considered the same as an empty object.
445444
</t>
446445
<t>
447-
Validation of this keyword against the instance always succeeds.
446+
This keyword controls child instance validation. Validation of the
447+
primitive instance type against this keyword always succeeds.
448448
</t>
449449
<t>
450450
Child validation succeeds if, for each name that appears in both
@@ -464,7 +464,8 @@
464464
If absent, it can be considered the same as an empty object.
465465
</t>
466466
<t>
467-
Validaton of this keyword against the instance always succeeds.
467+
This keyword controls child instance validation. Validation of the
468+
primitive instance type against this keyword always succeeds.
468469
</t>
469470
<t>
470471
Child validation succeeds if, for each instance name that matches any
@@ -484,27 +485,17 @@
484485
an empty schema as a value.
485486
</t>
486487
<t>
487-
If "additionalProperties" is either true or a schema, or if the instance
488-
is not an object, validation against the instance always succeeds.
489-
</t>
490-
<t>
491-
If "additionalProperties" is false and the instance is an object,
492-
validation against the instance succeeds only if all properties names
493-
in the instance match a name specified in "properties" and/or match
494-
at least one regular expression specified in "patternProperties".
488+
This keyword controls child instance validation. Validation of the
489+
primitive instance type against this keyword always succeeds.
495490
</t>
496491
<t>
497492
Child validation with "additionalProperties" applies only to the child
498-
valuse of instance names that do not match any names in "properties",
493+
values of instance names that do not match any names in "properties",
499494
and do not match any regular expression in "patternProperties".
500495
</t>
501496
<t>
502-
If "additionalProperties" is true, child validation always succeeds.
503-
</t>
504-
<t>
505-
If "additionalProperties" is a schema, child validation succeeds if
506-
all child instances to which "additionalProperties" applies validate
507-
against that schema.
497+
For all such properties, child validation succeeds if the child instance
498+
validates agains the "additionalProperties" schema.
508499
</t>
509500
</section>
510501

0 commit comments

Comments
 (0)