Skip to content

Commit abca457

Browse files
authored
Merge pull request #573 from handrews/dep-split
Split "requiredDependencies" out of "dependencies"
2 parents 8bccb31 + 72e4dc1 commit abca457

File tree

2 files changed

+42
-29
lines changed

2 files changed

+42
-29
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: 23 additions & 29 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,21 @@
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>
469-
</t>
470-
<t>
471-
This keyword specifies rules that are evaluated if the instance is an object and
472-
contains a certain property.
455+
The value of this keyword MUST be an object. Properties in
456+
this object, if any, MUST be arrays. Elements in each array,
457+
if any, MUST be strings, and MUST be unique.
473458
</t>
474459
<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.
460+
This keyword specifies properties that are required if a specific
461+
other property is present.
477462
</t>
478463
<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.
464+
Validation succeeds if, for each name that appears in both
465+
the instance and as a name within this keyword's value, every
466+
item in the corresponding array is also the name of a property
467+
in the instance.
487468
</t>
488469
<t>
489470
Omitting this keyword has the same behavior as an empty object.
@@ -1067,6 +1048,18 @@
10671048
as a generic mechanism on which validation, hyper-schema, and extension
10681049
vocabularies can all be based
10691050
</t>
1051+
<t hangText='"dependencies"'>
1052+
This keyword had two different modes of behavior, which made it
1053+
relatively challenging to implement and reason about.
1054+
The schema form has been moved to Core under the original
1055+
"dependencies" keyword, as part of the applicator vocabulary.
1056+
It is analogous to "properties", except that instead of applying
1057+
its subschema to the property value, it applies it to the object
1058+
containing the property.
1059+
The property name array form is retained here and renamed to
1060+
"requiredDependencies", as it is an assertion which is a shortcut
1061+
for the conditional use of the "required" assertion keyword.
1062+
</t>
10701063
</list>
10711064
</t>
10721065
</section>
@@ -1106,6 +1099,7 @@
11061099
<list style="symbols">
11071100
<t>Moved "definitions" to the core spec as "$defs"</t>
11081101
<t>Moved applicator keywords to the core spec</t>
1102+
<t>Renamed the array form of "dependencies" to "requiredDependencies", moved the schema form to the core spec</t>
11091103
</list>
11101104
</t>
11111105
<t hangText="draft-handrews-json-schema-validation-01">

0 commit comments

Comments
 (0)