Skip to content

Commit 300bf9d

Browse files
committed
Replaced the "requires" attribute with the "dependencies" attribute.
1 parent 9c54134 commit 300bf9d

File tree

2 files changed

+19
-22
lines changed

2 files changed

+19
-22
lines changed

draft-zyp-json-schema-03.xml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -337,26 +337,15 @@ If the property is not defined or is not in this list, than any type of value is
337337
<section title="required">
338338
<t>This attribute indicates if the instance must have a value, and not be undefined. This is false by default, making the instance optional.</t>
339339
</section>
340-
<section title="requires">
341-
<t>If this attribute value is a string, then the containing/parent object of the validating instance MUST have a property with a name of the attribute value in order to validate.
342-
If this attribute value is a schema, then the containing/parent object of the validating instance MUST be validated against the provided schema.</t>
343-
<figure>
344-
<preamble>For example, for the following schema:</preamble>
345-
<artwork><![CDATA[
346-
{
347-
"properties" : {
348-
"state":{
349-
"optional":true
350-
},
351-
"town":{
352-
"requires":"state",
353-
"optional":true
354-
}
355-
}
356-
}
357-
]]></artwork>
358-
<postamble>An instance MUST include a state property if a town property is included. If a town property is not included, the state property is optional.</postamble>
359-
</figure>
340+
<section title="dependencies">
341+
<t>This attribute is an object that defines the requirements of a property on an instance object. If an object instance has a property with the same name as a property in this attribute's object, then the instance must be valid against the attribute's property value (hereafter referred to as the "dependency value").</t>
342+
<t>
343+
The dependency value can take one of two forms:
344+
<list style="hanging">
345+
<t hangText="Simple Dependency">If the dependency value is an array of strings, then the instance object MUST have a property with the same name as each string in the dependency value's array.</t>
346+
<t hangText="Schema Dependency">If the dependency value is a schema, then the instance object MUST be valid against the schema.</t>
347+
</list>
348+
</t>
360349
</section>
361350
<section title="minimum">
362351
<t>This attribute defines the minimum value of the instance property when the type of the instance value is a number.</t>
@@ -938,6 +927,7 @@ instead of numbers</t>
938927
<t>Replaced "optional" attribute with "required" attribute.</t>
939928
<t>Replaced "maximumCanEqual" attribute with "exclusiveMaximum" attribute.</t>
940929
<t>Replaced "minimumCanEqual" attribute with "exclusiveMinimum" attribute.</t>
930+
<t>Replaced "requires" attribute with "dependencies" attribute.</t>
941931
<t>Moved "default" and "contentEncoding" attributes to hyper schema</t>
942932
<t>Added "additionalItems" attribute.</t>
943933
<t>Added "id" attribute.</t>

schema

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,15 @@
3939
"default" : {}
4040
},
4141

42-
"requires" : {
43-
"type" : ["string", "#"]
42+
"dependencies" : {
43+
"type" : "object",
44+
"additionalProperties" : {
45+
"type" : ["array", "#"],
46+
"items" : {
47+
"type" : "string"
48+
}
49+
},
50+
"default" : {}
4451
},
4552

4653
"minimum" : {

0 commit comments

Comments
 (0)