Skip to content

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

@gneginskiy

Description

@gneginskiy

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

Activity

changed the title [-]can't validate const values via schema[/-] [+]can't validate a doc against the schema containing "const"[/+] on Sep 21, 2020
Relequestual

Relequestual commented on Nov 4, 2020

@Relequestual

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Relequestual@gneginskiy

        Issue actions

          can't validate a doc against the schema containing "const" · Issue #352 · java-json-tools/json-schema-validator