Reputation: 51
I have been experimenting with ajv-cli
and trying to make it to verify a json scheme that makes use of standard formats like "ipv4" and "host-name".
Despite of having ajv-formats
installed, when invoked as:
ajv --strict=false --validate-formats=true compile -s 2438.schema.json
ajv
complains:
unknown format "host-name" ignored in schema at path "#/definitions/ip-address/anyOf/0"
unknown format "host-name" ignored in schema at path "#/definitions/ip-address/anyOf/0"
unknown format "ipv4" ignored in schema at path "#/definitions/ip-address/anyOf/1"
unknown format "ipv4" ignored in schema at path "#/definitions/ip-address/anyOf/1"
unknown format "ipv6" ignored in schema at path "#/definitions/ip-address/anyOf/2"
unknown format "ipv6" ignored in schema at path "#/definitions/ip-address/anyOf/2"
How do I make ajv-cli
to accept standard formats? Am I missing something obvious?
Thanks in advance!
Upvotes: 5
Views: 1787
Reputation: 1284
I faced the same situation today, trying to get acquainted with a specific json schema. I searched for a validation tool, and found ajv-cli
.
> npm install ajv-cli
> npx ajv validate -s maDMP-schema-1.1.json -d foo.json
schema maDMP-schema-1.1.json is invalid
error: unknown format "email" ignored in schema at path "#/properties/dmp/properties/contact/properties/mbox"
It took me a while before I discovered the -c option:
> npm install ajv-formats
> npx ajv validate -s maDMP-schema-1.1.json -d foo.json -c ajv-formats
foo.json valid
Hope it's the right way to do it!
Upvotes: 13