@@ -1714,62 +1714,35 @@ against the schema defined by this keyword.
1714
1714
1715
1715
#### Keywords for Applying Subschemas Conditionally {#conditional}
1716
1716
1717
- Three of these keywords work together to implement conditional application of a
1718
- subschema based on the outcome of another subschema. The fourth is a shortcut
1719
- for a specific conditional case.
1717
+ These keywords contain subschemas which are conditionally applied based on the
1718
+ instance.
1720
1719
1721
- ` if ` , ` then ` , and ` else ` MUST NOT interact with each other across subschema
1722
- boundaries. In other words, an ` if ` in one branch of an ` allOf ` MUST NOT have an
1723
- impact on a ` then ` or ` else ` in another branch.
1720
+ ##### ` if ` , ` then ` , and ` else `
1724
1721
1725
- There is no default behavior for ` if ` , ` then ` , or ` else ` when they are not
1726
- present. In particular, they MUST NOT be treated as if present with an empty
1727
- schema, and when ` if ` is not present, both ` then ` and ` else ` MUST be entirely
1728
- ignored.
1722
+ These three keywords work together to implement conditional application of a
1723
+ subschema based on the outcome of another subschema.
1729
1724
1730
- ##### ` if `
1725
+ The value for each of these keywords value MUST be a valid JSON Schema.
1731
1726
1732
- This keyword's value MUST be a valid JSON Schema.
1733
-
1734
- This validation outcome of this keyword's subschema has no direct effect on the
1735
- overall validation result. Rather, it controls which of the ` then ` or ` else `
1736
- keywords are evaluated.
1737
-
1738
- Instances that successfully validate against this keyword's subschema MUST also
1739
- be valid against the subschema value of the ` then ` keyword, if present.
1740
-
1741
- Instances that fail to validate against this keyword's subschema MUST also be
1742
- valid against the subschema value of the ` else ` keyword, if present.
1743
-
1744
- If [ annotations] ( #annotations ) are being collected, they are collected from this
1745
- keyword's subschema in the usual way, including when the keyword is present
1746
- without either ` then ` or ` else ` .
1747
-
1748
- ##### ` then `
1727
+ The ` if ` keyword produces an annotation which is the boolean validation result
1728
+ of its subschema against the instance. The validation outcome of the ` if `
1729
+ keyword's subschema MUST NOT directly effect the overall validation result.
1749
1730
1750
- This keyword's value MUST be a valid JSON Schema.
1751
-
1752
- When ` if ` is present, and the instance successfully validates against its
1753
- subschema, then validation succeeds against this keyword if the instance also
1754
- successfully validates against this keyword's subschema.
1755
-
1756
- This keyword has no effect when ` if ` is absent, or when the instance fails to
1757
- validate against its subschema. Implementations MUST NOT evaluate the instance
1758
- against this keyword, for either validation or annotation collection purposes,
1759
- in such cases.
1760
-
1761
- ##### ` else `
1762
-
1763
- This keyword's value MUST be a valid JSON Schema.
1731
+ The ` then ` and ` else ` keywords each consume the annotation from an adjacent ` if `
1732
+ keyword and conditionally apply their subschemas to the instance as follows:
1764
1733
1765
- When ` if ` is present, and the instance fails to validate against its subschema,
1766
- then validation succeeds against this keyword if the instance successfully
1767
- validates against this keyword's subschema.
1734
+ - When the annotation from the ` if ` keyword is ` true ` , the ` then ` keyword's
1735
+ subschema MUST be applied to the instance and the ` else ` keyword's subschema
1736
+ MUST be ignored.
1737
+ - When the annotation from the ` if ` keyword is ` false ` , the ` else ` keyword's
1738
+ subschema MUST be applied to the instance and the ` then ` keyword's subschema
1739
+ MUST be ignored.
1740
+ - When there is no adjacent ` if ` keyword, no annotation can be produced, so both
1741
+ the ` then ` and ` else ` keywords' subschemas MUST be ignored.
1768
1742
1769
- This keyword has no effect when ` if ` is absent, or when the instance
1770
- successfully validates against its subschema. Implementations MUST NOT evaluate
1771
- the instance against this keyword, for either validation or annotation
1772
- collection purposes, in such cases.
1743
+ If [ annotations] ( #annotations ) are being collected, they are collected from the
1744
+ subschemas which are evaluated, including from the ` if ` keyword's subschema when
1745
+ it is present without adjacent ` then ` or ` else ` keywords.
1773
1746
1774
1747
##### ` dependentSchemas `
1775
1748
0 commit comments