From 15ff80cd6e63ce09759338fed6a8fc93e9c92b6c Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Mon, 12 Dec 2016 11:00:24 -0800 Subject: [PATCH] Restore exclusive* dependencies, update metaschema 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. --- jsonschema-validation.xml | 6 ++++++ schema.json | 39 +++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/jsonschema-validation.xml b/jsonschema-validation.xml index c979e8c0..7d92335f 100644 --- a/jsonschema-validation.xml +++ b/jsonschema-validation.xml @@ -257,6 +257,9 @@ 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. + + If "exclusiveMaximum" is a boolean, then "maximum" MUST be present, and "exclusiveMinimum" (if present) MUST also be a boolean. + The boolean form of "exclusiveMaximum" is expected to be removed in the future. @@ -280,6 +283,9 @@ 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. + + If "exclusiveMinimum" is a boolean, then "minimum" MUST be present, and "exclusiveMaximum" (if present) MUST also be a boolean. + The boolean form of "exclusiveMinimum" is expected to be removed in the future. diff --git a/schema.json b/schema.json index 15502e9b..a08e21a4 100644 --- a/schema.json +++ b/schema.json @@ -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": [ + { + "exclusiveMaximum": { + "type": "number" + }, + "exclusiveMinimum": { + "type": "number" + } + }, + { + "exclusiveMaximum": { + "type": "boolean", + "default": false + }, + "exclusiveMinimum": { + "type": "boolean", + "default": false + }, + "dependencies": { + "exclusiveMaximum": [ "maximum" ], + "exclusiveMinimum": [ "minimum" ] + } + } + ], "maxLength": { "$ref": "#/definitions/positiveInteger" }, "minLength": { "$ref": "#/definitions/positiveIntegerDefault0" }, "pattern": { @@ -144,9 +159,5 @@ "oneOf": { "$ref": "#/definitions/schemaArray" }, "not": { "$ref": "#" } }, - "dependencies": { - "exclusiveMaximum": [ "maximum" ], - "exclusiveMinimum": [ "minimum" ] - }, "default": {} }