Is there a replacement for --unknown-formats?
Hello,
The --unknown-formats option is gone. Is there a replacement?
My use case is using a schema for which a format has validation implemented in Python but I don't necessarily have an implementation that I can plug to ajv.
Thank you
You can either disable format validation entirely or define it in a .js plugin and pass via -c option. so the file would look like:
module.export = (ajv) => ajv.addFormat("your_format", true)
I see.
To be honest, neither is really appealing.
Having to have .js plugins around to use ajv-cli doesn't sound quite right.
To give more context, we have schemas that do this:
"definitions": {
"something": {
"format": "custom",
"pattern": ...
}
}
For which we write validation functions often in Python and we have "pattern" as a fallback
@gpakosz If you can use the formats defined in https://github.com/ajv-validator/ajv-formats#formats, then you can easily add them with the following two steps:
npm i -D ajv-formats- Add
-c ajv-formatsto your CLI command forajx.
Example:
ajv test -s my.schema.json -d my.json --spec=draft2019 -c ajv-formats --valid --all-errors --errors=text
If you can not use those formats then you should look at ajv-cli-custom.