Skip to content

Commit 1b9d5a1

Browse files
feat: drop nullable const support
1 parent ab900c8 commit 1b9d5a1

File tree

2 files changed

+2
-8
lines changed

2 files changed

+2
-8
lines changed

index.js

-6
Original file line numberDiff line numberDiff line change
@@ -765,12 +765,6 @@ function buildValue (location, input) {
765765
let funcName
766766

767767
if ('const' in schema) {
768-
if (nullable) {
769-
code += `
770-
json += ${input} === null ? 'null' : '${JSON.stringify(schema.const)}'
771-
`
772-
return code
773-
}
774768
code += `json += '${JSON.stringify(schema.const)}'`
775769
return code
776770
}

test/const.test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ test('schema with const and null as type', (t) => {
238238
foo: null
239239
})
240240

241-
t.equal(output, '{"foo":null}')
241+
t.equal(output, '{"foo":"baz"}')
242242
t.ok(validate(JSON.parse(output)), 'valid schema')
243243

244244
const output2 = stringify({ foo: 'baz' })
@@ -262,7 +262,7 @@ test('schema with const as nullable', (t) => {
262262
foo: null
263263
})
264264

265-
t.equal(output, '{"foo":null}')
265+
t.equal(output, '{"foo":"baz"}')
266266
t.ok(validate(JSON.parse(output)), 'valid schema')
267267

268268
const output2 = stringify({

0 commit comments

Comments
 (0)