Skip to content

Commit 4d4d0bd

Browse files
authored
Merge pull request #554 from handrews/if-fixup
Fix missing "if present" for "else"
2 parents a8d0585 + 0bc8cde commit 4d4d0bd

File tree

1 file changed

+37
-23
lines changed

1 file changed

+37
-23
lines changed

jsonschema-validation.xml

Lines changed: 37 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -746,10 +746,23 @@
746746
branch of an "allOf" MUST NOT have an impact on a "then"
747747
or "else" in another branch.
748748
</t>
749+
<t>
750+
There is no default behavior for any of these keywords
751+
when they are not present. In particular, they MUST NOT
752+
be treated as if present with an empty schema, and when
753+
"if" is not present, both "then" and "else" MUST be
754+
entirely ignored.
755+
</t>
749756
<section title="if">
750757
<t>
751758
This keyword's value MUST be a valid JSON Schema.
752759
</t>
760+
<t>
761+
This validation outcome of this keyword's subschema
762+
has no direct effect on the overall validation
763+
result. Rather, it controls which of the "then"
764+
or "else" keywords are evaluated.
765+
</t>
753766
<t>
754767
Instances that successfully validate against this
755768
keyword's subschema MUST also be valid against
@@ -759,49 +772,50 @@
759772
<t>
760773
Instances that fail to validate against this
761774
keyword's subschema MUST also be valid against
762-
the subschema value of the "else" keyword.
775+
the subschema value of the "else" keyword, if
776+
present.
763777
</t>
764778
<t>
765-
Validation of the instance against this keyword
766-
on its own always succeeds, regardless of the
767-
validation outcome of against its subschema.
779+
If <xref target="annotations">annotations</xref>
780+
are being collected, they are collected from this
781+
keyword's subschema in the usual way, including when
782+
the keyword is present without either "then" or "else".
768783
</t>
769784
</section>
770785
<section title="then">
771786
<t>
772787
This keyword's value MUST be a valid JSON Schema.
773788
</t>
774789
<t>
775-
When present alongside of "if", the instance
776-
successfully validates against this keyword if
777-
it validates against both the "if"'s subschema
778-
and this keyword's subschema.
790+
When "if" is present, and the instance successfully
791+
validates against its subschema, then valiation
792+
succeeds against this keyword if the instance also
793+
successfully validates against this keyword's subschema.
779794
</t>
780795
<t>
781-
When "if" is absent, or the instance fails to
782-
validate against its subschema, validation against
783-
this keyword always succeeds. Implementations
784-
SHOULD avoid attempting to validate against
785-
the subschema in these cases.
796+
This keyword has no effect when "if" is absent, or
797+
when the instance fails to validate against its
798+
subschema. Implementations MUST NOT evaluate
799+
the instance against this keyword, for either validation
800+
or annotation collection purposes, in such cases.
786801
</t>
787802
</section>
788803
<section title="else">
789804
<t>
790805
This keyword's value MUST be a valid JSON Schema.
791806
</t>
792807
<t>
793-
When present alongside of "if", the instance
794-
successfully validates against this keyword if
795-
it fails to validate against the "if"'s
796-
subschema, and successfully validates against
797-
this keyword's subschema.
808+
When "if" is present, and the instance fails to
809+
validate against its subschema, then valiation
810+
succeeds against this keyword if the instance
811+
successfully validates against this keyword's subschema.
798812
</t>
799813
<t>
800-
When "if" is absent, or the instance successfully
801-
validates against its subschema, validation against
802-
this keyword always succeeds. Implementations
803-
SHOULD avoid attempting to validate against
804-
the subschema in these cases.
814+
This keyword has no effect when "if" is absent, or
815+
when the instance successfully validates against its
816+
subschema. Implementations MUST NOT evaluate
817+
the instance against this keyword, for either validation
818+
or annotation collection purposes, in such cases.
805819
</t>
806820
</section>
807821
</section>

0 commit comments

Comments
 (0)