Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Disabling format assertions for draft-07 doesn't seem to work #1144

Closed
michaelmior opened this issue Jan 16, 2025 · 4 comments · Fixed by #1145
Closed

Disabling format assertions for draft-07 doesn't seem to work #1144

michaelmior opened this issue Jan 16, 2025 · 4 comments · Fixed by #1145

Comments

@michaelmior
Copy link

michaelmior commented Jan 16, 2025

I'm trying to use a similar example to the one given in the README to force assertions to be disabled but when I execute this, I still get validation errors referring to the format. This also happens if I set the same option to false when building the config for the schema.

Set<ValidationMessage> = schema.validate(input, OutputFormat.DEFAULT, executionContext -> {
    // By default since Draft 07 the format keyword generates assertions
    executionContext.getExecutionConfig().setFormatAssertionsEnabled(false);
});

@stevehu
Copy link
Contributor

stevehu commented Jan 16, 2025

@michaelmior Thanks a lot for reporting it. Is it possible to create a test case to reproduce the issue? Thanks.

@michaelmior
Copy link
Author

michaelmior commented Jan 16, 2025

Here's a test case that currently fails. Let me know if you'd prefer I open a PR.

    @Test
    void draft7DisableFormat() {
        String schemaData = "{\r\n"
                + "  \"format\":\"uri\"\r\n"
                + "}";
        JsonSchema schema = JsonSchemaFactory.getInstance(VersionFlag.V7).getSchema(schemaData);
        Set<ValidationMessage> messages = schema.validate("\"hello\"", InputFormat.JSON, executionContext -> {
            executionContext.getExecutionConfig().setFormatAssertionsEnabled(false);
        });
        assertEquals(0, messages.size());
    }

@michaelmior
Copy link
Author

@stevehu Thanks for the fix!

@stevehu
Copy link
Contributor

stevehu commented Jan 17, 2025

@justin-tay fixed it. He is the best!!!

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

Successfully merging a pull request may close this issue.

2 participants