Skip to content

Commit

Permalink
Restore exclusive* dependencies, update metaschema
Browse files Browse the repository at this point in the history
This restores dependencies that got dropped somewhere between
draft 04 and 05 (not clear where).

It adds a reasonable restriction that the boolean vs numeric
forms not be mixed for exclusiveMinimum and exclusiveMaximum,
and implements the correct meta-scheam for this.  Which needs
a oneOf to corectly group the dependencies, but no longer needs
an extra allOf or anyOf to allow minimum and maximum to change
types independently.
  • Loading branch information
handrews committed Dec 12, 2016
1 parent e784d5d commit e4c7f53
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 14 deletions.
6 changes: 6 additions & 0 deletions jsonschema-validation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@
<t>
The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance, or a boolean. Schemas SHOULD NOT use the boolean form.
</t>
<t>
If "exclusiveMaximum" is a boolean, then "maximum" MUST be present, and "exclusiveMinimum" (if present) MUST also be a boolean.
</t>
<t>
<cref>The boolean form of "exclusiveMaximum" is expected to be removed in the future.</cref>
</t>
Expand All @@ -269,6 +272,9 @@
<t>
The value of "exclusiveMinimum" MUST be number, representing an exclusive upper limit for a numeric instance, or a boolean. Schemas SHOULD NOT use the boolean form.
</t>
<t>
If "exclusiveMinimum" is a boolean, then "minimum" MUST be present, and "exclusiveMaximum" (if present) MUST also be a boolean.
</t>
<t>
<cref>The boolean form of "exclusiveMinimum" is expected to be removed in the future.</cref>
</t>
Expand Down
39 changes: 25 additions & 14 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,38 @@
"default": {},
"multipleOf": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"minimum": {
"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"oneOf": [
{
"exclusiveMinimum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "maximum"
}
},
{
"exclusiveMaximum": {
"type": "boolean",
"default": false
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
"exclusiveMinimum": [ "minimum" ]
}
}
],
"maxLength": { "$ref": "#/definitions/positiveInteger" },
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
"pattern": {
Expand Down Expand Up @@ -155,9 +170,5 @@
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
"exclusiveMinimum": [ "minimum" ]
},
"default": {}
}

0 comments on commit e4c7f53

Please sign in to comment.