@@ -415,20 +415,37 @@ keywords MUST NOT begin with this prefix.
415
415
Implementations MUST refuse to evaluate schemas which contain keywords which
416
416
they do not know how to process or explicitly choose not to process.
417
417
418
- ## Keyword Behaviors
418
+ ## Keyword Behaviors {#keyword-behaviors}
419
419
420
- JSON Schema keywords fall into several general behavior categories. Assertions
421
- validate that an instance satisfies constraints, producing a boolean result.
422
- Annotations attach information that applications may use in any way they see
423
- fit. Applicators apply subschemas to parts of the instance and combine their
424
- results.
420
+ JSON Schema keywords may exhibit one or more behaviors. This specification
421
+ defines three such behaviors:
422
+
423
+ - Assertions validate that an instance satisfies constraints, producing a
424
+ boolean result: ` true ` if the constraints are satisfied; ` false ` otherwise.
425
+ - Annotations attach information that applications may use in any way they see
426
+ fit.
427
+ - Applicators apply subschemas to parts of the instance and combine their
428
+ results.
425
429
426
- Extension keywords SHOULD stay within these categories , keeping in mind that
430
+ Extension keywords SHOULD be defined using these behaviors , keeping in mind that
427
431
annotations in particular are extremely flexible. Complex behavior is usually
428
432
better delegated to applications on the basis of annotation data than
429
433
implemented directly as schema keywords. However, extension keywords MAY define
430
434
other behaviors for specialized purposes.
431
435
436
+ Keywords which are not defined to exhibit a particular behavior MUST NOT affect
437
+ that aspect of evalution. For example, a keyword which does not act as an
438
+ assertion MUST NOT affect the validation result.
439
+
440
+ For the purposes of this document, an instance "validating against a keyword"
441
+ means that the keyword produces an assertion result of ` true ` if the instance
442
+ satisfies the given constraint; otherwise an assertion result of ` false ` is
443
+ produced.
444
+
445
+ <!-- The next two paragraphs and the following section seem to have to more to
446
+ do with schema evaluation than keywords specifically. I'd like to move them out
447
+ of the "keyword behaviors" h2, but will do so separately. [TODO: GD] -->
448
+
432
449
Evaluating an instance against a schema involves processing all of the keywords
433
450
in the schema against the appropriate locations within the instance. Typically,
434
451
applicator keywords are processed until a schema object with no applicators (and
@@ -569,11 +586,11 @@ the keyword's value. Alternatively, an applicator may refer to a schema
569
586
elsewhere in the same schema document, or in a different one. The mechanism for
570
587
identifying such referenced schemas is defined by the keyword.
571
588
572
- Applicator keywords also define how subschema or referenced schema boolean
573
- [ assertion] ( #assertions ) results are modified and/or combined to produce the
574
- boolean result of the applicator. Applicators may apply any boolean logic
575
- operation to the assertion results of subschemas, but MUST NOT introduce new
576
- assertion conditions of their own.
589
+ Applicator keywords also behave as assertions by defining how subschema or
590
+ referenced schema boolean [ assertion] ( #assertions ) results are modified and/or
591
+ combined to produce the boolean result of the applicator. Applicators may apply
592
+ any boolean logic operation to the assertion results of subschemas, but MUST NOT
593
+ introduce new assertion conditions of their own.
577
594
578
595
[ Annotation] ( #annotations ) results from subschemas are preserved in accordance
579
596
with {{collect}} so that applications can decide how to interpret multiple
@@ -1001,11 +1018,16 @@ identified schema. Its results are the results of the referenced schema.[^5]
1001
1018
[ ^ 5 ] : Note that this definition of how the results are determined means that
1002
1019
other keywords can appear alongside of ` $ref ` in the same schema object.
1003
1020
1021
+ The value of the ` $ref ` keyword MUST be a string which is an IRI reference.
1004
1022
The value of the ` $ref ` keyword MUST be a string which is an IRI reference.
1005
1023
Resolved against the current IRI base, it produces the IRI of the schema to
1006
1024
apply. This resolution is safe to perform on schema load, as the process of
1007
1025
evaluating an instance cannot change how the reference resolves.
1008
1026
1027
+ The resolved IRI produced by ` $ref ` is not necessarily a network locator, only
1028
+ an identifier. A schema need not be downloadable from the address if it is a
1029
+ network-addressable URL. Implementations which can access the network SHOULD
1030
+ default to operating offline.
1009
1031
The resolved IRI produced by ` $ref ` is not necessarily a network locator, only
1010
1032
an identifier. A schema need not be downloadable from the address if it is a
1011
1033
network-addressable URL. Implementations which can access the network SHOULD
@@ -1476,8 +1498,8 @@ operators can contact the owner of a potentially misbehaving script.
1476
1498
1477
1499
## Keywords for Applying Subschemas
1478
1500
1479
- This section defines a set of keywords that enable schema combinations and
1480
- composition.
1501
+ This section defines a set of applicator keywords that enable schema
1502
+ combinations and composition.
1481
1503
1482
1504
### Keywords for Applying Subschemas in Place {#in-place}
1483
1505
@@ -1737,8 +1759,8 @@ The value of this keyword MUST be a non-negative integer.
1737
1759
This keyword modifies the behavior of ` contains ` within the same schema object,
1738
1760
as described below in the section for that keyword.
1739
1761
1740
- Validation MUST always succeed against this keyword . The value of this keyword
1741
- is used as its annotation result.
1762
+ This keyword produces no assertion result . The value of this keyword is used as
1763
+ its annotation result.
1742
1764
1743
1765
##### ` minContains `
1744
1766
@@ -1747,8 +1769,8 @@ The value of this keyword MUST be a non-negative integer.
1747
1769
This keyword modifies the behavior of ` contains ` within the same schema object,
1748
1770
as described below in the section for that keyword.
1749
1771
1750
- Validation MUST always succeed against this keyword . The value of this keyword
1751
- is used as its annotation result.
1772
+ This keyword produces no assertion result . The value of this keyword is used as
1773
+ its annotation result.
1752
1774
1753
1775
Per {{default-behaviors}}, omitted keywords MUST NOT produce annotation results.
1754
1776
However, as described in {{contains}}, the absence of this keyword's annotation
0 commit comments