Skip to content

Commit

Permalink
tests: add failing tests for typeforce.oneOf, and fix oneOf behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Oct 6, 2016
1 parent beee3f6 commit 9fa4135
Show file tree
Hide file tree
Showing 5 changed files with 996 additions and 10 deletions.
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,11 @@ var types = {

function _oneOf (value, strict) {
return types.some(function (type) {
return type(value, strict)
try {
return typeforce(type, value, strict)
} catch (e) {
return false
}
})
}
_oneOf.toJSON = function () { return types.map(tfJSON).join('|') }
Expand Down

0 comments on commit 9fa4135

Please sign in to comment.