Ajv: Checking validity of keywords

Created on 3 May 2018  路  2Comments  路  Source: ajv-validator/ajv

Currently ajv does not provide any option to check whatever the keywords you use are valid or not. Such option could be useful to reduce typos but more importantly ease the migration from other schema validation libraries and prevent using similar keywords used by other tools. (such as some orms where you might get used to use "max" instead of "maximum", or "allowedValues" instead of "enum")

It's a trivial task to check if a schema is valid or not, but since ajv already aware of valid keywords and can track custom ones I think having a such built-in feature would be nice.

enhancement option

Most helpful comment

Given the complexity of extending meta-schema in the specification, and also the fact that ajv doesn't require it for custom keywords (and instead accepts their "meta-schemas" as part of their definition), I think it can be useful to have an option unknownKeywords: 'ignore'(default)|'fail'|'log'} that would make Ajv throw exception or log in case any unknown keyword is used.

It should support (as known) all defined/reserved annotation keywords as well.

All 2 comments

Given the complexity of extending meta-schema in the specification, and also the fact that ajv doesn't require it for custom keywords (and instead accepts their "meta-schemas" as part of their definition), I think it can be useful to have an option unknownKeywords: 'ignore'(default)|'fail'|'log'} that would make Ajv throw exception or log in case any unknown keyword is used.

It should support (as known) all defined/reserved annotation keywords as well.

in 6.10.0

Was this page helpful?
0 / 5 - 0 ratings