You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This keyword specifies subschemas that are evaluated if the instance is an
99
-
object and contains a certain property with a certain string value.
100
-
101
-
This keyword's value MUST be an object. Each value in the object MUST be an
102
-
object whose values MUST be valid JSON Schemas.
103
-
104
-
If the outer object key is a property in the instance and the inner object key
105
-
is equal to the value of that property, the entire instance must validate
106
-
against the schema. Its use is dependent on the presence and value of the
107
-
property.
108
-
109
-
Omitting this keyword has the same behavior as an empty object.
81
+
## Change Description
82
+
83
+
1. The following will be added to the JSON Schema Core specification as a
84
+
subsection of "Keywords for Applying Subschemas Conditionally".
85
+
> ### `propertyDependencies`
86
+
>
87
+
> This keyword specifies subschemas that are evaluated if the instance is an
88
+
> object and contains a certain property with a certain string value.
89
+
>
90
+
> This keyword's value MUST be an object. Each value in the object MUST be an
91
+
> object whose values MUST be valid JSON Schemas.
92
+
>
93
+
> If the outer object key is a property in the instance and the inner object key
94
+
> is equal to the value of that property, the entire instance must validate
95
+
> against the schema. Its use is dependent on the presence and value of the
96
+
> property.
97
+
>
98
+
> Omitting this keyword has the same behavior as an empty object.
99
+
2. The following subschema will be added to the Applicator Vocabulary schema, `https://json-schema.org/<version>/<release>/meta/applicator` at `/properties/propertyDependencies`:
100
+
```json
101
+
{
102
+
"type": "object",
103
+
"additionalProperties": {
104
+
"type": "object",
105
+
"additionalProperties": {
106
+
"$dynamicRef": "#meta",
107
+
"default": true
108
+
},
109
+
"default": {}
110
+
}
111
+
}
112
+
```
110
113
111
114
## [Appendix] Problems With Existing Patterns {#problems}
112
115
@@ -172,115 +175,6 @@ avoid it.
172
175
}
173
176
```
174
177
175
-
## [Appendix] Alternatives Considered {#alternatives}
176
-
177
-
Here are some alternatives that were considered that support all value types.
178
-
All examples have the same validation behavior as the examples above.
179
-
180
-
This version uses an array of objects. Each object is a collection of the
181
-
variables needed to express a property dependency. This doesn't fit the style of
182
-
JSON Schema. There aren't any keywords remotely like this. It's also still too
183
-
verbose. It's a little more intuitive than `if`/`then` and definitely less error
184
-
prone.
185
-
186
-
```jsonschema
187
-
{
188
-
"propertyDependencies": [
189
-
{
190
-
"propertyName": "foo",
191
-
"propertySchema": { "const": "aaa" },
192
-
"apply": { "$ref": "#/$defs/foo-aaa" }
193
-
},
194
-
{
195
-
"propertyName": "foo",
196
-
"propertySchema": { "const": "bbb" },
197
-
"apply": { "$ref": "#/$defs/foo-bbb" }
198
-
}
199
-
]
200
-
}
201
-
```
202
-
203
-
A slight variation on that example is to make it a map of keyword to dependency
204
-
object. It's still too verbose.
205
-
206
-
```jsonschema
207
-
{
208
-
"propertyDependencies": {
209
-
"foo": [
210
-
{
211
-
"propertySchema": { "const": "aaa" },
212
-
"apply": { "$ref": "#/$defs/foo-aaa" }
213
-
},
214
-
{
215
-
"propertySchema": { "const": "bbb" },
216
-
"apply": { "$ref": "#/$defs/foo-bbb" }
217
-
}
218
-
]
219
-
}
220
-
}
221
-
```
222
-
223
-
This one is a little more consistent with the JSON Schema style (poor keyword
224
-
naming aside), but otherwise has all the same problems as the other examples.
0 commit comments