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

can't validate a doc against the schema containing "const" #352

Open
gneginskiy opened this issue Sep 21, 2020 · 1 comment
Open

can't validate a doc against the schema containing "const" #352

gneginskiy opened this issue Sep 21, 2020 · 1 comment

Comments

@gneginskiy
Copy link

gneginskiy commented Sep 21, 2020

Hi guys.

Due to some reason the library cannot validate the sample json against the schema using const values by the link:
https://www.jsonschemavalidator.net/s/myuH8UPz

expected: validation is passed
actual: validation fails

however, if I replace all the const s with a single string enum, everything works as expected

e.g.
"type": {"const": "backButton"},
with
"type": {"type": "string", "enum": ["backButton"]},

version used: 2.2.14

sample code:

            JsonNode contextNode = JsonLoader.fromString(StringEscapeUtils.unescapeJava(jsonDocument));
            JsonValidator validator = JsonSchemaFactory.byDefault().getValidator();
            ProcessingReport report = validator.validate(jsonSchema, contextNode); //contains errors

can you please have a look

Thanks,
Grigory

@gneginskiy gneginskiy changed the title can't validate const values via schema can't validate a doc against the schema containing "const" Sep 21, 2020
@Relequestual
Copy link

This library only supports draft 3 and 4. const was added later. You'll need to pick another library.

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

2 participants