Skip to content

Commit

Permalink
fix: defined() so it doesn't mark a schema as nullable
Browse files Browse the repository at this point in the history
BREAKING CHANGE: defined() now doesn't automatically allow null, this was a bug. to mimic the old behavior add nullable() to schema with defined()
  • Loading branch information
jquense committed Nov 19, 2020
1 parent 57d42a8 commit f08d507
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ const proto = (SchemaType.prototype = {
},

defined(message = locale.defined) {
return this.nullable().test({
return this.test({
message,
name: 'defined',
exclusive: true,
Expand Down
4 changes: 2 additions & 2 deletions test/mixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
});
Expand Down

0 comments on commit f08d507

Please sign in to comment.