Skip to content

Validation meta-schema: Implement "exclusiveMaximum"/"exclusiveMinimum" changes #185

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,22 +46,19 @@
"default": {},
"multipleOf": {
"type": "number",
"minimum": 0,
"exclusiveMinimum": true
"exclusiveMinimum": 0
},
"maximum": {
"type": "number"
},
"exclusiveMaximum": {
"type": "boolean",
"default": false
"type": ["number", "boolean"]
},
"minimum": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this been removed? It's in the spec document.

"type": "number"
},
"exclusiveMinimum": {
"type": "boolean",
"default": false
"type": ["number", "boolean"]
},
"maxLength": { "$ref": "#/definitions/positiveInteger" },
"minLength": { "$ref": "#/definitions/positiveIntegerDefault0" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as previous.

Expand Down Expand Up @@ -147,9 +144,5 @@
"oneOf": { "$ref": "#/definitions/schemaArray" },
"not": { "$ref": "#" }
},
"dependencies": {
"exclusiveMaximum": [ "maximum" ],
"exclusiveMinimum": [ "minimum" ]
},
"default": {}
Copy link
Member

@epoberezkin epoberezkin Dec 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be:

"dependencies": {
  "exclusiveMaximum": {
    "anyOf": [
      {
        "properties": {
          "exclusiveMaximum": { "type": "number" },
          "maximum": false
        }
      },
      {
        "properties": {
          "exclusiveMaximum": { "type": "boolean" },
          "maximum": true
        }
      }
    ]
  }
}

Copy link
Member

@epoberezkin epoberezkin Dec 20, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And with if/the/else it would look more elegant :)

"dependencies": {
  "exclusiveMaximum": {
    "if": { "properties": { "exclusiveMaximum": { "type": "boolean" } } },
    "then": { "required": ["maximum"] },
    "else": { "not": { "required": ["maximum"] } }
  }
}

the else branch requires that "maximum" keyword is absent when "exclusiveMaximum" is present, which can be dropped as a requirement - maybe having them both is ok.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I gotta say, these solutions make me feel a lot better about pushing this forward, and how well JSON Schema is designed in general.

}