@@ -410,20 +410,37 @@ keywords MUST NOT begin with this prefix.
410
410
Implementations MUST refuse to evaluate schemas which contain keywords which
411
411
they do not know how to process or explicitly choose not to process.
412
412
413
- ## Keyword Behaviors
413
+ ## Keyword Behaviors {#keyword-behaviors}
414
414
415
- JSON Schema keywords fall into several general behavior categories. Assertions
416
- validate that an instance satisfies constraints, producing a boolean result.
417
- Annotations attach information that applications may use in any way they see
418
- fit. Applicators apply subschemas to parts of the instance and combine their
419
- results.
415
+ JSON Schema keywords may exhibit one or more behaviors. This specification
416
+ defines three such behaviors:
417
+
418
+ - Assertions validate that an instance satisfies constraints, producing a
419
+ boolean result: ` true ` if the constraints are satisfied; ` false ` otherwise.
420
+ - Annotations attach information that applications may use in any way they see
421
+ fit.
422
+ - Applicators apply subschemas to parts of the instance and combine their
423
+ results.
420
424
421
- Extension keywords SHOULD stay within these categories , keeping in mind that
425
+ Extension keywords SHOULD be defined using these behaviors , keeping in mind that
422
426
annotations in particular are extremely flexible. Complex behavior is usually
423
427
better delegated to applications on the basis of annotation data than
424
428
implemented directly as schema keywords. However, extension keywords MAY define
425
429
other behaviors for specialized purposes.
426
430
431
+ Keywords which are not defined to exhibit a particular behavior MUST NOT affect
432
+ that aspect of evalution. For example, a keyword which does not act as an
433
+ assertion MUST NOT affect the validation result.
434
+
435
+ For the purposes of this document, an instance "validating against a keyword"
436
+ means that the keyword produces an assertion result of ` true ` if the instance
437
+ satisfies the given constraint; otherwise an assertion result of ` false ` is
438
+ produced.
439
+
440
+ <!-- The next two paragraphs and the following section seem to have to more to
441
+ do with schema evaluation than keywords specifically. I'd like to move them out
442
+ of the "keyword behaviors" h2, but will do so separately. [TODO: GD] -->
443
+
427
444
Evaluating an instance against a schema involves processing all of the keywords
428
445
in the schema against the appropriate locations within the instance. Typically,
429
446
applicator keywords are processed until a schema object with no applicators (and
@@ -564,11 +581,11 @@ the keyword's value. Alternatively, an applicator may refer to a schema
564
581
elsewhere in the same schema document, or in a different one. The mechanism for
565
582
identifying such referenced schemas is defined by the keyword.
566
583
567
- Applicator keywords also define how subschema or referenced schema boolean
568
- [ assertion] ( #assertions ) results are modified and/or combined to produce the
569
- boolean result of the applicator. Applicators may apply any boolean logic
570
- operation to the assertion results of subschemas, but MUST NOT introduce new
571
- assertion conditions of their own.
584
+ Applicator keywords also behave as assertions by defining how subschema or
585
+ referenced schema boolean [ assertion] ( #assertions ) results are modified and/or
586
+ combined to produce the boolean result of the applicator. Applicators may apply
587
+ any boolean logic operation to the assertion results of subschemas, but MUST NOT
588
+ introduce new assertion conditions of their own.
572
589
573
590
[ Annotation] ( #annotations ) results from subschemas are preserved in accordance
574
591
with {{collect}} so that applications can decide how to interpret multiple
@@ -993,21 +1010,22 @@ identified schema. Its results are the results of the referenced schema.[^5]
993
1010
[ ^ 5 ] : Note that this definition of how the results are determined means that
994
1011
other keywords can appear alongside of ` $ref ` in the same schema object.
995
1012
996
- The value of the ` $ref ` keyword MUST be a string which is a IRI reference.
1013
+ The value of the ` $ref ` keyword MUST be a string which is an IRI reference.
997
1014
Resolved against the current IRI base, it produces the IRI of the schema to
998
1015
apply. This resolution is safe to perform on schema load, as the process of
999
1016
evaluating an instance cannot change how the reference resolves.
1000
1017
1001
- The resolved IRI produced by ` $ref ` is not necessarily a network
1002
- locator, only an identifier. A schema need not be downloadable from the address
1003
- if it is a network-addressable URL. Implementations which can access the network
1004
- SHOULD default to operating offline.
1018
+ The resolved IRI produced by ` $ref ` is not necessarily a network locator, only
1019
+ an identifier. A schema need not be downloadable from the address if it is a
1020
+ network-addressable URL. Implementations which can access the network SHOULD
1021
+ default to operating offline.
1005
1022
1006
1023
##### Dynamic References with ` $dynamicRef ` {#dynamic-ref}
1007
1024
1008
1025
The ` $dynamicRef ` keyword is an applicator that allows for deferring the full
1009
1026
resolution until runtime, at which point it is resolved each time it is
1010
- encountered while evaluating an instance.
1027
+ encountered while evaluating an instance. Its results are the results of the
1028
+ referenced schema.
1011
1029
1012
1030
Together with ` $dynamicAnchor ` , ` $dynamicRef ` implements a cooperative extension
1013
1031
mechanism that is primarily useful to to create open schemas, where
@@ -1465,8 +1483,8 @@ operators can contact the owner of a potentially misbehaving script.
1465
1483
1466
1484
## Keywords for Applying Subschemas
1467
1485
1468
- This section defines a set of keywords that enable schema combinations and
1469
- composition.
1486
+ This section defines a set of applicator keywords that enable schema
1487
+ combinations and composition.
1470
1488
1471
1489
### Keywords for Applying Subschemas in Place {#in-place}
1472
1490
@@ -1727,8 +1745,8 @@ The value of this keyword MUST be a non-negative integer.
1727
1745
This keyword modifies the behavior of ` contains ` within the same schema object,
1728
1746
as described below in the section for that keyword.
1729
1747
1730
- Validation MUST always succeed against this keyword . The value of this keyword
1731
- is used as its annotation result.
1748
+ This keyword produces no assertion result . The value of this keyword is used as
1749
+ its annotation result.
1732
1750
1733
1751
##### ` minContains `
1734
1752
@@ -1737,8 +1755,8 @@ The value of this keyword MUST be a non-negative integer.
1737
1755
This keyword modifies the behavior of ` contains ` within the same schema object,
1738
1756
as described below in the section for that keyword.
1739
1757
1740
- Validation MUST always succeed against this keyword . The value of this keyword
1741
- is used as its annotation result.
1758
+ This keyword produces no assertion result . The value of this keyword is used as
1759
+ its annotation result.
1742
1760
1743
1761
Per {{default-behaviors}}, omitted keywords MUST NOT produce annotation results.
1744
1762
However, as described in {{contains}}, the absence of this keyword's annotation
0 commit comments