From fe7f91d06b8507d8bfe2e21552b9c02ce9a8431c Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin Date: Sun, 10 Feb 2019 08:39:18 +0000 Subject: [PATCH] fix: incorrect custom keyword definition schema, #941 --- README.md | 2 +- lib/keyword.js | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7bc1dca..5ddefa1 100644 --- a/README.md +++ b/README.md @@ -1011,7 +1011,7 @@ Keyword definition is an object with the following properties: - _valid_: pass `true`/`false` to pre-define validation result, the result returned from validation function will be ignored. This option cannot be used with macro keywords. - _$data_: an optional `true` value to support [$data reference](#data-reference) as the value of custom keyword. The reference will be resolved at validation time. If the keyword has meta-schema it would be extended to allow $data and it will be used to validate the resolved value. Supporting $data reference requires that keyword has validating function (as the only option or in addition to compile, macro or inline function). - _async_: an optional `true` value if the validation function is asynchronous (whether it is compiled or passed in _validate_ property); in this case it should return a promise that resolves with a value `true` or `false`. This option is ignored in case of "macro" and "inline" keywords. -- _errors_: an optional boolean indicating whether keyword returns errors. If this property is not set Ajv will determine if the errors were set in case of failed validation. +- _errors_: an optional boolean or string `"full"` indicating whether keyword returns errors. If this property is not set Ajv will determine if the errors were set in case of failed validation. _compile_, _macro_ and _inline_ are mutually exclusive, only one should be used at a time. _validate_ can be used separately or in addition to them to support $data reference. diff --git a/lib/keyword.js b/lib/keyword.js index 44d3fec..53d95c6 100644 --- a/lib/keyword.js +++ b/lib/keyword.js @@ -34,7 +34,12 @@ var definitionSchema = { valid: {type: 'boolean'}, $data: {type: 'boolean'}, async: {type: 'boolean'}, - errors: {type: 'boolean'} + errors: { + anyOf: [ + {type: 'boolean'}, + {const: 'full'} + ] + } } };