From a31684c5e76aadb9ca15f67c44295f3ddfe955f5 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Fri, 23 Mar 2018 15:22:11 -0700 Subject: [PATCH 1/2] 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" --- jsonschema-core.xml | 19 ++++++++++++++ jsonschema-validation.xml | 52 ++++++++++++++++----------------------- 2 files changed, 40 insertions(+), 31 deletions(-) diff --git a/jsonschema-core.xml b/jsonschema-core.xml index b2600944..557f2747 100644 --- a/jsonschema-core.xml +++ b/jsonschema-core.xml @@ -1295,6 +1295,24 @@ Omitting this keyword has the same behavior as an empty schema. + +
+ + This keyword specifies subschemas that are evaluated if the instance + is an object and contains a certain property. + + + This keyword's value MUST be an object. + Each value in the object MUST be a valid JSON Schema. + + + If the object key is a property in the instance, the entire + instance must validate against the dependency value. + + + Omitting this keyword has the same behavior as an empty object. + +
@@ -1625,6 +1643,7 @@ User-Agent: product-name/5.4.1 so-cool-json-schema/1.0.2 curl/7.43.0 Moved "definitions" from the Validation specification here as "$defs" Moved applicator keywords from the Validation specification as their own vocabulary + Moved "dependencies" from the Validation specification, but only the schema form diff --git a/jsonschema-validation.xml b/jsonschema-validation.xml index ab1b1a47..653ad28e 100644 --- a/jsonschema-validation.xml +++ b/jsonschema-validation.xml @@ -223,10 +223,6 @@ Validation keywords in a schema impose requirements for successful validation of an instance. These keywords are all assertions without any annotation behavior. - - "dependencies" has applicator behavior, but this keyword will be split - into separate assertion and applicator keywords before the next draft publication. -
@@ -454,36 +450,17 @@
-
+
- - This keyword may be split into two, with the variation that uses - an array of property names rather than a subschema getting a new - name. The dual behavior is confusing and relatively difficult to - implement. In the previous draft, we proposed dropping the keyword - altogether, or dropping one of its forms, but we received feedback - in support of keeping it. See issues #442 and #528 at - <https://github.com/json-schema-org/json-schema-spec/issues> - for further discussion. Further feedback is encouraged. - + This keyword specifies property requirements that are conditional + based on the presence of other properties. - This keyword specifies rules that are evaluated if the instance is an object and - contains a certain property. - - - This keyword's value MUST be an object. Each property specifies a dependency. - Each dependency value MUST be an array or a valid JSON Schema. - - - If the dependency value is a subschema, and the dependency key is a property - in the instance, the entire instance must validate against the dependency value. - - - If the dependency value is an array, each element in the array, - if any, MUST be a string, and MUST be unique. If the dependency key is - a property in the instance, each of the items in the dependency - value must be a property that exists in the instance. + This keyword's value MUST be an object. Each property specifies + a dependent requirement, which MUST be an array. Each element + in the array, if any, MUST be a string, and MUST be unique. + If the dependency key is a property in the instance, each of the items + in the dependency value MUST be a property that exists in the instance. Omitting this keyword has the same behavior as an empty object. @@ -1067,6 +1044,18 @@ as a generic mechanism on which validation, hyper-schema, and extension vocabularies can all be based + + This keyword had two different modes of behavior, which made it + relatively challenging to implement and reason about. + The schema form has been moved to Core under the original + "dependencies" keyword, as part of the applicator vocabulary. + It is analogous to "properties", except that instead of applying + its subschema to the property value, it applies it to the object + containing the property. + The property name array form is retained here and renamed to + "requiredDependencies", as it is an assertion which is a shortcut + for the conditional use of the "required" assertion keyword. +
@@ -1106,6 +1095,7 @@ Moved "definitions" to the core spec as "$defs" Moved applicator keywords to the core spec + Renamed the array form of "dependencies" to "requiredDependencies", moved the schema form to the core spec From 72e4dc1acca49d2cb7f04366d2de51b71d2b8584 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Wed, 4 Apr 2018 09:58:52 -0700 Subject: [PATCH 2/2] Rework requiredDependencies to be more consistent Use language based on a combination of "required" and "properties", and make the simple description (the 2nd paragraph) more clear. --- jsonschema-validation.xml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/jsonschema-validation.xml b/jsonschema-validation.xml index 653ad28e..f0123a33 100644 --- a/jsonschema-validation.xml +++ b/jsonschema-validation.xml @@ -452,15 +452,19 @@
- This keyword specifies property requirements that are conditional - based on the presence of other properties. + The value of this keyword MUST be an object. Properties in + this object, if any, MUST be arrays. Elements in each array, + if any, MUST be strings, and MUST be unique. - This keyword's value MUST be an object. Each property specifies - a dependent requirement, which MUST be an array. Each element - in the array, if any, MUST be a string, and MUST be unique. - If the dependency key is a property in the instance, each of the items - in the dependency value MUST be a property that exists in the instance. + This keyword specifies properties that are required if a specific + other property is present. + + + Validation succeeds if, for each name that appears in both + the instance and as a name within this keyword's value, every + item in the corresponding array is also the name of a property + in the instance. Omitting this keyword has the same behavior as an empty object.