From 0781a56415dd2ed44af602cbef2625bccf38cbd7 Mon Sep 17 00:00:00 2001 From: Fudong Fan Date: Tue, 10 Jul 2018 09:56:35 -0400 Subject: [PATCH] Added schema property !enum Just the inverse of the existing property "enum" --- lib/revalidator.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/revalidator.js b/lib/revalidator.js index 58476b0..f17bdf3 100644 --- a/lib/revalidator.js +++ b/lib/revalidator.js @@ -114,6 +114,7 @@ additionalProperties: "must not exist" }; validate.messages['enum'] = "must be present in given enumerator"; + validate.messages['notEnum'] = "must not be present in given enumerator"; /** * @@ -295,6 +296,10 @@ if (schema['enum'] && schema['enum'].indexOf(value) === -1) { error('enum', property, value, schema, errors); } + + if (schema['notEnum'] && schema['notEnum'].indexOf(value) > -1 ) { + error('notEnum', property, value, schema, errors); + } // Dependencies (see 5.8) if (typeof schema.dependencies === 'string' &&