From 1b9d5a1d52e4e4b96a64d431d1e8921951ee0ccf Mon Sep 17 00:00:00 2001 From: ivan-tymoshenko Date: Fri, 2 Sep 2022 18:24:30 +0300 Subject: [PATCH] feat: drop nullable const support --- index.js | 6 ------ test/const.test.js | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/index.js b/index.js index a4c43b56..b6c2e79b 100644 --- a/index.js +++ b/index.js @@ -765,12 +765,6 @@ function buildValue (location, input) { let funcName if ('const' in schema) { - if (nullable) { - code += ` - json += ${input} === null ? 'null' : '${JSON.stringify(schema.const)}' - ` - return code - } code += `json += '${JSON.stringify(schema.const)}'` return code } diff --git a/test/const.test.js b/test/const.test.js index c0b0b0aa..84706704 100644 --- a/test/const.test.js +++ b/test/const.test.js @@ -238,7 +238,7 @@ test('schema with const and null as type', (t) => { foo: null }) - t.equal(output, '{"foo":null}') + t.equal(output, '{"foo":"baz"}') t.ok(validate(JSON.parse(output)), 'valid schema') const output2 = stringify({ foo: 'baz' }) @@ -262,7 +262,7 @@ test('schema with const as nullable', (t) => { foo: null }) - t.equal(output, '{"foo":null}') + t.equal(output, '{"foo":"baz"}') t.ok(validate(JSON.parse(output)), 'valid schema') const output2 = stringify({