Allow nullable property of JSON Schema object to be false as well as true. Remove test that asserted failure if nullable was false.

master
Mathew Polzin 2019-02-06 23:34:14 -08:00
parent 6d4b31e169
commit 28c85ada05
2 changed files with 1 additions and 7 deletions

View File

@ -70,7 +70,7 @@ function Ajv(opts) {
if (opts.formats) addInitialFormats(this);
addDefaultMetaSchema(this);
if (typeof opts.meta == 'object') this.addMetaSchema(opts.meta);
if (opts.nullable) this.addKeyword('nullable', {metaSchema: {const: true}});
if (opts.nullable) this.addKeyword('nullable', {metaSchema: {type: "boolean"}});
addInitialSchemas(this);
}

View File

@ -1519,12 +1519,6 @@ describe('Ajv Options', function () {
testNotNullable({type: ['number']});
});
it('"nullable" keyword must be "true" if present', function() {
should.throw(function() {
ajv.compile({nullable: false});
});
});
});
describe('without option "nullable"', function() {