Add ajv-formats to the ajv resolver
See original GitHub issueIs your feature request related to a problem? Please describe. A lot of people, including myself, use ajv-formats as an extension for ajv.
ajv-formats makes it easy and secure to validate emails, urls, uuids, and many others string formats.
At the moment the ajv resolver does not include it, which means JSON Schemas properties with format
do not compile and are
not validated.
I would like to highlight that ajv-formats is an official package under the ajv validator.
Describe the solution you’d like Include ajv-formats as part of the ajv resolver.
Describe alternatives you’ve considered Creating another ajv resolver with ajv-formats. I don’t think this is the best idea, as adding ajv-formats by default does not cause any damage. The only thing it does is enhancing the grammar to support formats. Giving the the grammar is currently not “pure”, because it already includes ajv-errors, I don’t think this is a big issue. Alternative implemented here: https://github.com/react-hook-form/resolvers/pull/434
Additional context Change already implemented here in this PR: https://github.com/react-hook-form/resolvers/pull/431
Issue Analytics
- State:
- Created a year ago
- Reactions:3
- Comments:8 (3 by maintainers)
This would be a great addition to this ajvResolver. I would argue that people use ajv and jsonschema precisly because of very specific validation rule needs. Hence adding format-validation would make perfect sense. I do understand the trade-off being made here in favor of the more generic approach though. Only… the more generic a library becomes, the less useful it is (can’t remember where this quote came from)
Going back to my original comment, please build a custom resolver for your use case. I don’t think we prefer this external package to be a dep for everyone’s use case with AJV.