-
-
Notifications
You must be signed in to change notification settings - Fork 26
Description
JSON Schema has never required that the format
keyword be validated. Since 2019-09, it's been required that it's not validated by default. For these reasons, I never chose to add support for validating format
. I do want to support it eventually, but it's never been a priority.
I think this would be a good task for someone looking to contribute to open source. It's relatively straightforward, but requires proficiency with regular expressions, attention to detail, and the ability to read and understand RFCs. For each format, you'll need to understand the syntax and determine the best way to validate it. Sometimes that will be a regular expression, sometimes you'll need to find an appropriate library. There might be a case or two where you need to write the code to validate the format yourself, but mostly this should be about finding and using the right resource. The rest is just configuring the implementation for the keyword/vocabulary.
Acceptance Criteria
- Must include a test runner for and pass all format tests in the official test suite
- All defined formats are supported (Spec)
-
date-time
-
date
-
time
-
duration
-
email
-
idn-email
-
hostname
-
idn-hostname
-
ipv4
-
ipv6
-
uri
(Use @hyperjump/uri) -
uri-reference
(Use @hyperjump/uri) -
iri
(Use @hyperjump/uri) -
iri-reference
(Use @hyperjump/uri) -
uuid
-
uri-template
-
json-pointer
-
relative-json-pointer
-
regex
-
- Validation is off by default in all dialects and can be enabled by setting a config
- In 2019-09, the format vocabulary set to
true
enables validation by default but can still be disabled by config - By default, only formats defined by the dialect the schema uses are validated. Other formats are not enabled even if they are defined for another dialect. (Example:
uuid
should not be validated in draft-07)- draft-04 -
date-time
,email
,hostname
,ipv4
,ipv6
,uri
- draft-06 -
date-time
,email
,hostname
,ipv4
,ipv6
,uri
,uri-reference
,uri-template
,json-pointer
- draft-07 -
date-time
,date
,time
,email
,idn-email
,hostname
,idn-hostname
,ipv4
,ipv6
,uri
,uri-reference
,iri
,iri-reference
,uri-template
,json-pointer
,relative-json-pointer
,regex
- 2019-09 -
date-time
,date
,time
,duration
,email
,idn-email
,hostname
,idn-hostname
,ipv4
,ipv6
,uri
,uri-reference
,iri
,iri-reference
,uuid
,uri-template
,json-pointer
,relative-json-pointer
,regex
- 2020-12 -
date-time
,date
,time
,duration
,email
,idn-email
,hostname
,idn-hostname
,ipv4
,ipv6
,uri
,uri-reference
,iri
,iri-reference
,uuid
,uri-template
,json-pointer
,relative-json-pointer
,regex
- draft-04 -
- In draft-04/6/7, unknown formats return
true
- In 2019-09 with the format vocabulary set to
false
, unknown formats returntrue
- In 2019-09 with the format vocabulary set to
true
, unknown formats throw an error - In 2020-12 with the format-annotation vocabulary, unknown formats return
true
- In 2020-12 with the format-assertion vocabulary, unknown formats throw an error
- Users can enable a defined format in a draft that didn't define it yet. (Example: enabling
uuid
in draft-07 schema) - Users can define and enable custom formats for specific dialects
- Annotations are collected when validation is enabled
- Works in node.js and the browser
- When validation is off, its code must not be bundled
- Bundle size for browsers should be kept as small as possible (Be careful about including large dependencies)
- Update README