Skip to content

Add formatValidation option, default to spec behavior per draft - #161

Open
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:format-assertion-option
Open

Add formatValidation option, default to spec behavior per draft#161
jnbdz wants to merge 1 commit into
eclipse-vertx:masterfrom
SiteNetSoft:format-assertion-option

Conversation

@jnbdz

@jnbdz jnbdz commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #160

Motivation

Since draft 2019-09 the specification defines format as 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

  • New JsonSchemaOptions.setFormatValidation(Boolean):
    • unset (default): draft-dependent — asserted up to draft-7 (unchanged), annotation-only from 2019-09 on (spec default);
    • true: always assert; false: never assert.
  • SchemaValidatorImpl resolves the effective behavior once in its constructor (after draft resolution, since the draft may come from $schema) and gates the built-in Format.fastFormat check. The pluggable JsonFormatValidator is unaffected — supplying one is already an explicit opt-in.
  • The 34 "invalid X string is only an annotation by default" entries for 2019-09/2020-12 are removed from unsupported-tck-tests.properties and now pass. The optional/format suites run with formatValidation(true), per the test-suite guidance that they assume the format-assertion behavior.
  • Documented in the asciidoc; new FormatValidationTest covers all drafts × default/forced-on/forced-off.

⚠️ Behavior change

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 to true (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.

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
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

Successfully merging this pull request may close these issues.

format is asserted by default under 2019-09/2020-12, contrary to the specification

1 participant