microsoft / microsoft/vscode-json-languageservice

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

Open
#71 13 comments 1 reaction 1 assignee View on GitHub

@aeschli is already working on this.

Since Aug 26, 2020.

feature-request
Dominant language
TypeScript
Stars
326
Forks
145
Avg merge
22h 10m
Merged PRs (30d)
9

Description

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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.