Skip to content

draft/2019-09: exclusiveMinimum and exclusiveMaximum must be numbers #71

@saman

Description

@saman

In my workspace, if I put $schema to 2019-09, and set exclusiveMinimum and exclusiveMaximum with a boolean is not throwing any error.

Considering these two examples:

A JSON Schema based on draft-07

{
    "$id": "https://example.com/my-schema",
    "$schema": "https://json-schema.org/draft-07/schema",
    "properties": {
        "test": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "maximum": 100,
            "exclusiveMaximum": true
        }
    }
}

And a JSON Schema based on lastest version draft 2019-09

{
    "$id": "https://example.com/my-schema",
    "$schema": "https://json-schema.org/draft/2019-09/schema",
    "properties": {
        "test": {
            "type": "number",
            "minimum": 0,
            "exclusiveMinimum": true,
            "maximum": 100,
            "exclusiveMaximum": true
        }
    }
}

The example with draft 2019-09 is going to be accepted, while the first example with draft-07 throws an error as expected:
Incorrect type. Expected "number".

As I can see in jsonParser.ts is going to accept both number and boolean on 2019-09 which is incorrect while It is showing an expected error on draft-09.
2019-09 draft specefication mention this:

6.2.3. exclusiveMaximum
The value of "exclusiveMaximum" MUST be number, representing an exclusive upper limit for a numeric instance.

6.2.5. exclusiveMinimum
The value of "exclusiveMinimum" MUST be number, representing an exclusive lower limit for a numeric instance.

Metadata

Metadata

Assignees

Labels

feature-requestRequest for new features or functionality

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions