Closed b-wils closed 1 month ago
Yeah, it's not that easy to setup an Ajv instance that "just" supports any schema draft, from Draft 6 and 7 to 2019 and 2020.
The API of createAjvValidator
has an option onCreateAjv: (ajv: Ajv) => Ajv | void
which allows you to alter the Ajv instance or return an instance that you create yourself. That way you can load draft 2020-12, and you don't need to do the error mapping stuff yourself.
Help improving this with a better default behavior of createAjvValidator
would be welcome though!
Ah that did the trick, thanks! I'll look into improving default behavior when I have some time.
I have a schema that is Draft 2020-12 and specified as instructed in https://json-schema.org/understanding-json-schema/reference/schema.
I'm getting the following error when passing the schema into createAjvValidator -
Digging into the ajv docs, looks like there are some slight changes to how you initialize the library for ajv- https://ajv.js.org/guide/schema-language.html#draft-2019-09-and-draft-2020-12.
I also attempted to instantiate ajv directly and pass it in directly, but it seems like the type jsoneditor expects is slightly different and I would need to pull in
immutable-json-patch
to remap the error list.Is this something that is supported, or something that could be added?