json-schema-spec
json-schema-spec copied to clipboard
Proposal: Make `format` validate by default
There's a long and sticky history around format
.
- Going back all the way to Draft 01,
format
has never required validation. - Whether to support
format
validation has always been the decision of the implementation. - The extent to which formats are validated has also been the decision of the implementation.
The result of all of this is that implementation support for validation has been spotty at best. Despite the JSON Schema specs referencing very concretely defined formats (by referencing other specs), implementations that do support validation don't all support each format equally. This has been the primary driving force behind keeping format
as an opt-in validation.
With 2019-09, we decided that it was time to give the option of format
validation to the schema author. They could enable validation by using a meta-schema which listed the Format Vocabulary with a true
value, which meant, "format
validation is required to process this schema."
In 2020-12, we further refined this by offering two separate vocabularies, one that treats the keyword as an annotation and one that treats it as an assertion. The argument was that the behavior of a keyword shouldn't change based on whether the vocabulary was required or not.
However, the fact remains that our users consistently report (via questions in Slack, GitHub, and StackOverflow) that they expect format
to validate. (The most recent case I can think of was only last week, in .Net's effort to build a short-term solution for schema generation from types.)
This consistency in user expectations leads me to believe that we should officially make format
an assertion keyword and strictly enforce it by moving the appropriate tests into the required section of the Test Suite.
(Personally, I'm not passing all of the optional format
tests, so I'll have to do some work to get there or document why they're not supported.)