Skip to content

Commit

Permalink
fix: noUnknown() overriding (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam authored and jquense committed Feb 7, 2019
1 parent 7705972 commit 3047b33
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ inherits(ObjectSchema, MixedSchema, {
},
});

if (noAllow) next._options.stripUnknown = true;
next._options.stripUnknown = noAllow;

return next;
},
Expand Down
11 changes: 11 additions & 0 deletions test/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,17 @@ describe('Object types', () => {
]);
});

it('should work with noUnknown override', async () => {
let inst = object()
.shape({
prop: mixed(),
})
.noUnknown()
.noUnknown(false);

await inst.validate({ extra: 'field' }).should.become({ extra: 'field' });
});

it('should strip specific fields', () => {
let inst = object().shape({
prop: mixed().strip(false),
Expand Down

0 comments on commit 3047b33

Please sign in to comment.