From f08d507a60699c429d221e6d91bba08c0a698fe1 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Thu, 19 Nov 2020 09:48:04 -0500 Subject: [PATCH] fix: defined() so it doesn't mark a schema as nullable BREAKING CHANGE: defined() now doesn't automatically allow null, this was a bug. to mimic the old behavior add nullable() to schema with defined() --- src/mixed.js | 2 +- test/mixed.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mixed.js b/src/mixed.js index 8ee9e8946..a69d28a6d 100644 --- a/src/mixed.js +++ b/src/mixed.js @@ -592,7 +592,7 @@ const proto = (SchemaType.prototype = { }, defined(message = locale.defined) { - return this.nullable().test({ + return this.test({ message, name: 'defined', exclusive: true, diff --git a/test/mixed.js b/test/mixed.js index ecddab4ac..729c405b2 100644 --- a/test/mixed.js +++ b/test/mixed.js @@ -960,13 +960,13 @@ describe('Mixed Types ', () => { it('should pass when value is null', async () => { let inst = object({ - prop: string().defined(), + prop: string().nullable().defined(), }); await inst.isValid({ prop: null }).should.eventually().equal(true); }); - it('should pass when value is not undefined nor null', async () => { + it('should pass when value is not undefined', async () => { let inst = object({ prop: string().defined(), });