Skip to content
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

Validation of enums that are numbers stopped working in 1.8.0 #790

Closed
1 of 4 tasks
fredriklengstrand opened this issue Jul 1, 2022 · 4 comments
Closed
1 of 4 tasks
Assignees
Milestone

Comments

@fredriklengstrand
Copy link

Describe the bug

It appears that validation of enums that are numbers stopped working in 1.8.0.
More concerning is that it also prevents other properties from validating when you use this property in the YAML file.

Sample schema

{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "first": {
            "type": "string",
            "enum": ["a", "b"]
        },
        "second": {
            "type": "number",
            "enum": [1, 2]
        }
    }
}

Sample YAML

# yaml-language-server: $schema=./test.schema.json
first: c
second: 3

Expected Behavior

I should get an error that both properties are invalid.

Current Behavior

No errors are shown for either of the properties.

Steps to Reproduce

Use the provided sample files and try commenting out / enabling the second property and you will see that the validation for first starts working / stops working.

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
@msivasubramaniaan msivasubramaniaan added this to the 1.9.0 milestone Jul 4, 2022
@msivasubramaniaan msivasubramaniaan self-assigned this Jul 4, 2022
@beanaroo
Copy link

beanaroo commented Jul 5, 2022

I was curious as I'm trying this extension out for the first time and it seems that enum of type number is causing the issue.

@msivasubramaniaan
Copy link
Contributor

I was curious as I'm trying this extension out for the first time and it seems that enum of type number is causing the issue.

Yes the issue related to number type. And the issue was addressed and the fix will be available on the new v1.9.0
image

@msivasubramaniaan
Copy link
Contributor

@beanaroo and @fredriklengstrand as new YAML v1.9.1 was released and please check the mentioned issue on the corresponding version.

@fredriklengstrand
Copy link
Author

@msivasubramaniaan Thank you for looking into this. I have done some testing and there still seems to be some issues left when you have defined a number enum and then for example input a string in there instead. That stops all validation from working. With the schema I sent over before, this stops all validation:

# yaml-language-server: $schema=./test.schema.json
first: c
second: a

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants