Skip to content

Commit a31684c

Browse files
committed
Split "requiredDependencies" out of "dependencies"
"dependencies", with the schema behavior, moves to the validation spec with the other applicators. "requiredDependencies", with the property array behavior, stays in validation as an assertion alongside "required"
1 parent 8bccb31 commit a31684c

File tree

2 files changed

+40
-31
lines changed

2 files changed

+40
-31
lines changed

jsonschema-core.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,24 @@
12951295
Omitting this keyword has the same behavior as an empty schema.
12961296
</t>
12971297
</section>
1298+
1299+
<section title="dependencies">
1300+
<t>
1301+
This keyword specifies subschemas that are evaluated if the instance
1302+
is an object and contains a certain property.
1303+
</t>
1304+
<t>
1305+
This keyword's value MUST be an object.
1306+
Each value in the object MUST be a valid JSON Schema.
1307+
</t>
1308+
<t>
1309+
If the object key is a property in the instance, the entire
1310+
instance must validate against the dependency value.
1311+
</t>
1312+
<t>
1313+
Omitting this keyword has the same behavior as an empty object.
1314+
</t>
1315+
</section>
12981316
</section>
12991317
</section>
13001318
</section>
@@ -1625,6 +1643,7 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0
16251643
<list style="symbols">
16261644
<t>Moved "definitions" from the Validation specification here as "$defs"</t>
16271645
<t>Moved applicator keywords from the Validation specification as their own vocabulary</t>
1646+
<t>Moved "dependencies" from the Validation specification, but only the schema form</t>
16281647
</list>
16291648
</t>
16301649
<t hangText="draft-handrews-json-schema-01">

jsonschema-validation.xml

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,6 @@
223223
<t>
224224
Validation keywords in a schema impose requirements for successful validation of an
225225
instance. These keywords are all assertions without any annotation behavior.
226-
<cref>
227-
"dependencies" has applicator behavior, but this keyword will be split
228-
into separate assertion and applicator keywords before the next draft publication.
229-
</cref>
230226
</t>
231227

232228
<section title="Validation Keywords for Any Instance Type" anchor="general">
@@ -454,36 +450,17 @@
454450
</t>
455451
</section>
456452

457-
<section title="dependencies">
453+
<section title="requiredDependencies">
458454
<t>
459-
<cref>
460-
This keyword may be split into two, with the variation that uses
461-
an array of property names rather than a subschema getting a new
462-
name. The dual behavior is confusing and relatively difficult to
463-
implement. In the previous draft, we proposed dropping the keyword
464-
altogether, or dropping one of its forms, but we received feedback
465-
in support of keeping it. See issues #442 and #528 at
466-
&lt;https://github.com/json-schema-org/json-schema-spec/issues&gt;
467-
for further discussion. Further feedback is encouraged.
468-
</cref>
455+
This keyword specifies property requirements that are conditional
456+
based on the presence of other properties.
469457
</t>
470458
<t>
471-
This keyword specifies rules that are evaluated if the instance is an object and
472-
contains a certain property.
473-
</t>
474-
<t>
475-
This keyword's value MUST be an object. Each property specifies a dependency.
476-
Each dependency value MUST be an array or a valid JSON Schema.
477-
</t>
478-
<t>
479-
If the dependency value is a subschema, and the dependency key is a property
480-
in the instance, the entire instance must validate against the dependency value.
481-
</t>
482-
<t>
483-
If the dependency value is an array, each element in the array,
484-
if any, MUST be a string, and MUST be unique. If the dependency key is
485-
a property in the instance, each of the items in the dependency
486-
value must be a property that exists in the instance.
459+
This keyword's value MUST be an object. Each property specifies
460+
a dependent requirement, which MUST be an array. Each element
461+
in the array, if any, MUST be a string, and MUST be unique.
462+
If the dependency key is a property in the instance, each of the items
463+
in the dependency value MUST be a property that exists in the instance.
487464
</t>
488465
<t>
489466
Omitting this keyword has the same behavior as an empty object.
@@ -1067,6 +1044,18 @@
10671044
as a generic mechanism on which validation, hyper-schema, and extension
10681045
vocabularies can all be based
10691046
</t>
1047+
<t hangText='"dependencies"'>
1048+
This keyword had two different modes of behavior, which made it
1049+
relatively challenging to implement and reason about.
1050+
The schema form has been moved to Core under the original
1051+
"dependencies" keyword, as part of the applicator vocabulary.
1052+
It is analogous to "properties", except that instead of applying
1053+
its subschema to the property value, it applies it to the object
1054+
containing the property.
1055+
The property name array form is retained here and renamed to
1056+
"requiredDependencies", as it is an assertion which is a shortcut
1057+
for the conditional use of the "required" assertion keyword.
1058+
</t>
10701059
</list>
10711060
</t>
10721061
</section>
@@ -1106,6 +1095,7 @@
11061095
<list style="symbols">
11071096
<t>Moved "definitions" to the core spec as "$defs"</t>
11081097
<t>Moved applicator keywords to the core spec</t>
1098+
<t>Renamed the array form of "dependencies" to "requiredDependencies", moved the schema form to the core spec</t>
11091099
</list>
11101100
</t>
11111101
<t hangText="draft-handrews-json-schema-validation-01">

0 commit comments

Comments
 (0)