Add formatValidation option, default to spec behavior per draft - #161
Open
jnbdz wants to merge 1 commit into
Open
Add formatValidation option, default to spec behavior per draft#161jnbdz wants to merge 1 commit into
jnbdz wants to merge 1 commit into
Conversation
Since draft 2019-09 the format keyword is an annotation by default, the validator however asserted formats unconditionally for every draft. Add JsonSchemaOptions.setFormatValidation: unset follows the draft in use (asserted up to draft-7, annotation only from 2019-09 on), true always asserts, false never asserts. The 34 skipped default-behavior format tests from the official test suite now run and pass; the optional format suites run with the assertion explicitly enabled per the test suite usage guidance. Fixes eclipse-vertx#160
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #160
Motivation
Since draft 2019-09 the specification defines
formatas an annotation by default; the validator asserts it unconditionally for every draft. This is stricter than the spec and keeps 34 default-behavior format tests from the official suite permanently skipped.Changes
JsonSchemaOptions.setFormatValidation(Boolean):true: always assert;false: never assert.SchemaValidatorImplresolves the effective behavior once in its constructor (after draft resolution, since the draft may come from$schema) and gates the built-inFormat.fastFormatcheck. The pluggableJsonFormatValidatoris unaffected — supplying one is already an explicit opt-in."invalid X string is only an annotation by default"entries for 2019-09/2020-12 are removed fromunsupported-tck-tests.propertiesand now pass. Theoptional/formatsuites run withformatValidation(true), per the test-suite guidance that they assume the format-assertion behavior.FormatValidationTestcovers all drafts × default/forced-on/forced-off.2019-09/2020-12 schemas that relied on format errors need
setFormatValidation(true)to restore the previous behavior (draft-4/7 are unchanged). Happy to flip the default totrue(pure opt-in, no behavior change, but the 34 TCK tests stay skipped) if you prefer backward compatibility over spec compliance — say the word and I'll adjust.Full suite: 4801 tests, 0 failures, skips down from 152 to 118.