question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add ajv-formats to the ajv resolver

See original GitHub issue

Is 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:open
  • Created a year ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
vanhumbeeckacommented, Jul 29, 2022

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)

4reactions
bluebill1049commented, Jul 20, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ajv options - Ajv JSON schema validator
Usage. This page describes properties of the options object that can be passed to Ajv constructor. For example, to report all validation errors...
Read more >
Ajv JSON schema validator - npm
Another JSON Schema Validator. Latest version: 8.11.2, last published: a month ago. Start using ajv in your project by running `npm i ajv`....
Read more >
AJV and ajv-formats latest must be broken in React
import Ajv from "ajv"; import AjvFormats from "ajv-formats"; import AjvErrors from "ajv-errors"; const ajv = new Ajv({ allErrors: true, strict: ...
Read more >
ajv-formats - npm Package Health Analysis - Snyk
ajv -formats · Format validation for Ajv v7+ For more information about how to use this package see README · Security · Popularity...
Read more >
Implementations - JSON Schema
General processing; Schema to Schema; Schema draft migration; Format converters ... Built on: ajv; License: MIT; Information last updated: 2022-08-31.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found