Skip to content

Commit

Permalink
feat: aliases optional() and unknown() (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam authored and jquense committed Feb 10, 2019
1 parent 1cac515 commit 51e8661
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/mixed.js
Original file line number Diff line number Diff line change
Expand Up @@ -512,3 +512,4 @@ for (const method of ['validate', 'validateSync'])

for (const alias of ['equals', 'is']) proto[alias] = proto.oneOf;
for (const alias of ['not', 'nope']) proto[alias] = proto.notOneOf;
proto.optional = proto.notRequired;
4 changes: 4 additions & 0 deletions src/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,10 @@ inherits(ObjectSchema, MixedSchema, {
return next;
},

unknown(allow = true, message = locale.noUnknown) {
return this.noUnknown(!allow, message);
},

transformKeys(fn) {
return this.transform(obj => obj && mapKeys(obj, (_, key) => fn(key)));
},
Expand Down

0 comments on commit 51e8661

Please sign in to comment.