Skip to content

Commit c55678a

Browse files
committed
Move applicability/attachement information.
Generalize this and move it into validation, updating the hyper-schema spec to reference it.
1 parent 4f9e4e3 commit c55678a

File tree

2 files changed

+71
-26
lines changed

2 files changed

+71
-26
lines changed

jsonschema-hyperschema.xml

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -174,32 +174,6 @@
174174
relations for the instance, with URIs incorporating values from the instance.
175175
</postamble>
176176
</figure>
177-
178-
<section title="Interaction with validation">
179-
<t>
180-
Hyper-schema keywords can be applied when the instance is valid against
181-
the schema that includes those keywords.
182-
</t>
183-
<t>
184-
Hyper-schemas MUST NOT be applied to an instance if the instance fails to
185-
validate against the validation keywords within or containing the hyper-schema.
186-
Hyper-schema keywords in branches of an "anyOf", "oneOf", or "if"/"then"/"else"
187-
that do not validate, or in a "dependencies" subschema that is not relevant
188-
to the instance, MUST be ignored.
189-
</t>
190-
<t>
191-
Hyper-schema keywords in a subschema contained within a "not", at any depth,
192-
including any number of intervening additional "not" subschemas, MUST be
193-
ignored.
194-
</t>
195-
<t>
196-
If the subschema for a "contains" keyword contains hyper-schema keywords they
197-
MUST be applied to all array elements that validate against the schema. While
198-
finding a single validating element is sufficient to determine the validation
199-
outcome, when hyper-schema keywords are present, the subschema MUST be evaluated
200-
against all array elements.
201-
</t>
202-
</section>
203177
</section>
204178

205179
<section title="Meta-schema">
@@ -210,6 +184,17 @@
210184
</section>
211185

212186
<section title="Schema keywords">
187+
<t>
188+
Hyper-schema keywords can be applied when the instance is valid against
189+
the schema that includes those keywords, as outlined in
190+
<xref target="json-schema-validation">Section 10.1 of JSON Schema validation</xref>.
191+
</t>
192+
<t>
193+
When multiple subschemas are applicable to a given sub-instance, all "link"
194+
arrays MUST be concatenated, in any order, into a single array. Each object
195+
in the resulting array MUST retain its own list of applicable "base" values,
196+
in resolution order, from the same schema and any parent schemas.
197+
</t>
213198
<section title="base">
214199
<t>
215200
If present, this keyword is resolved against the current URI base that the

jsonschema-validation.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1135,6 +1135,66 @@
11351135
</section>
11361136

11371137
<section title="Schema annotations and extension vocabularies">
1138+
<t>
1139+
Schema validation is a useful mechanism for annotating instance data
1140+
with additional information. This section describes the rules for
1141+
determining when and how annotations apply to an instance, and specifies
1142+
a small general-purpose annotation vocabulary.
1143+
</t>
1144+
<t>
1145+
Additional vocabularies SHOULD make use of this mechanism for applying
1146+
their keywords to instances.
1147+
</t>
1148+
<section title="Applicability and attachment">
1149+
<t>
1150+
Annotations can be applied to an instance when it is valid against
1151+
the schema that includes the annotation keywords. For any given location
1152+
in the instance (referred to as a sub-instance), each (sub)schema against
1153+
which it successfully validates is considered to be <spanx>applicable</spanx>
1154+
to that sub-instance. The (sub)schema is said to be <spanx>attached</spanx>
1155+
to each sub-instance to which it applies.
1156+
</t>
1157+
<t>
1158+
A validation implementation MAY choose to implement determining subschema
1159+
applicability and providing access to the value(s) of applicable annotation
1160+
keywords. Implementation of this feature MAY instead be done separately.
1161+
</t>
1162+
<t>
1163+
Since many subschemas can be applicable to any single sub-isntance, each
1164+
annotation keyword or vocabulary needs to specify how to handle multiple
1165+
occurrences with different values. In the absence of keyword-specific
1166+
handling rules, an implementation MUST collect all values and make them
1167+
available as a data structure in which order is not significant and items
1168+
need not be unique.
1169+
</t>
1170+
<section title="Combinatoric and conditional schemas">
1171+
<t>
1172+
Annotations in branches of an "anyOf", "oneOf", or "if"/"then"/"else"
1173+
that do not validate, or in a "dependencies" subschema that is not relevant
1174+
to the instance, MUST be ignored.
1175+
</t>
1176+
<t>
1177+
Annotations in a subschema contained within a "not", at any depth,
1178+
including any number of intervening additional "not" subschemas, MUST be
1179+
ignored.
1180+
</t>
1181+
</section>
1182+
<section title="Annotations and short-circuit validation">
1183+
<t>
1184+
Schema keywords MUST be applied to all possible sub-instances when
1185+
considering annotations, even if such application can be short-circuited
1186+
when only the overall validation result is needed.
1187+
</t>
1188+
<t>
1189+
An example of this is the "contains" keyword, which need only be evaluated
1190+
against array elements until it produces at least one successful outcome
1191+
in order to be implemented. However, when annotations are considered,
1192+
it must be checked against every array element, and the annotations MUST
1193+
be applied to every element that successfully validates against the
1194+
"contains" susbschema.
1195+
</t>
1196+
</section>
1197+
</section>
11381198

11391199
<section title='"title" and "description"'>
11401200
<t>

0 commit comments

Comments
 (0)