From 7402f98008c85a733c5d3ee48bac3fd3d648b16a Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Mon, 17 Aug 2020 11:36:58 +0100 Subject: [PATCH] fix: boolean schemas with strictKeywords option --- lib/dot/definitions.def | 3 ++- lib/dot/validate.jst | 2 +- spec/boolean.spec.js | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/dot/definitions.def b/lib/dot/definitions.def index db4ea6f32..709cce36d 100644 --- a/lib/dot/definitions.def +++ b/lib/dot/definitions.def @@ -64,7 +64,8 @@ {{## def.nonEmptySchema:_schema: (it.opts.strictKeywords - ? typeof _schema == 'object' && Object.keys(_schema).length > 0 + ? (typeof _schema == 'object' && Object.keys(_schema).length > 0) + || _schema === false : it.util.schemaHasRules(_schema, it.RULES.all)) #}} diff --git a/lib/dot/validate.jst b/lib/dot/validate.jst index fd833a535..32087e71c 100644 --- a/lib/dot/validate.jst +++ b/lib/dot/validate.jst @@ -81,7 +81,7 @@ it.baseId = it.baseId || it.rootId; delete it.isTop; - it.dataPathArr = [undefined]; + it.dataPathArr = [""]; if (it.schema.default !== undefined && it.opts.useDefaults && it.opts.strictDefaults) { var $defaultMsg = 'default is ignored in the schema root'; diff --git a/spec/boolean.spec.js b/spec/boolean.spec.js index c4c3b3eb1..0f493859c 100644 --- a/spec/boolean.spec.js +++ b/spec/boolean.spec.js @@ -11,7 +11,8 @@ describe('boolean schemas', function() { ajvs = [ new Ajv, new Ajv({allErrors: true}), - new Ajv({inlineRefs: false}) + new Ajv({inlineRefs: false}), + new Ajv({strictKeywords: true}), ]; });