atlassian / better-ajv-errors

JSON Schema validation for Human 👨‍🎤
https://atlassian.github.io/better-ajv-errors/
Other
232 stars 44 forks source link

Integration with ajv-errors (or otherwise support custom error messages) #139

Closed queengooborg closed 2 years ago

queengooborg commented 2 years ago

I am an owner of the MDN browser-compat-data project, and we use ajv with better-ajv-errors. As indicated in https://github.com/mdn/browser-compat-data/issues/3256, we are wanting to use ajv-errors for custom errors to better represent the situation where a subfeature contains invalid characters (which is caught by additionalProperties: false). Doing a quick experiment, however, I found that it seems that better-ajv-errors doesn't get along with ajv-errors. It seems that ajv-errors replaces the error type for some odd reason.

It would be really wonderful to see support included so we can use both at the same time. Happy to spend time to do this one!

torifat commented 2 years ago

Hey @queengooborg, I'm happy to accept contributions to support ajv-errors. AFAIR, we don't mutate anything inside better-ajv-errors.

queengooborg commented 2 years ago

I dug a little deeper into this, and I found that the original error data is moved into the params object, so a fix should be pretty straightforward. I'll get a PR opened for this soon!

torifat commented 2 years ago

https://github.com/atlassian/better-ajv-errors/releases/tag/v1.2.0 has been released on npm too. Thanks again for your contribution.