Skip to content

Commit

Permalink
Number and Boolean instances should be considered valid.
Browse files Browse the repository at this point in the history
  • Loading branch information
alpacaaa committed Dec 14, 2015
1 parent 90e1033 commit 067500b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/boolean.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function BooleanSchema(){
inherits(BooleanSchema, MixedSchema, {

_typeCheck(v){
return typeof v === 'boolean'
return (typeof v === 'boolean') || (typeof v === 'object' && v instanceof Boolean)
}
})

5 changes: 4 additions & 1 deletion src/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ function NumberSchema(){
inherits(NumberSchema, SchemaObject, {

_typeCheck(v) {
return typeof v === 'number' && !(v !== +v) //isNaN check
if ( typeof v === 'number' && !(v !== +v) ) return true
if ( typeof v === 'object' && v instanceof Number ) return true

return false
},

min(min, msg) {
Expand Down
1 change: 1 addition & 0 deletions test/bool.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('Boolean types', function(){
inst.isType('true').should.equal(false)
inst.isType(NaN).should.equal(false)
inst.isType(34545).should.equal(false)
inst.isType(new Boolean(false)).should.equal(true)
chai.expect(
inst.isType(null)).to.equal(false)
inst.nullable().isType(null).should.equal(true)
Expand Down
1 change: 1 addition & 0 deletions test/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ describe('Number types', function(){
var inst = number()

inst.isType(5).should.equal(true)
inst.isType(new Number(5)).should.equal(true)
inst.isType(false).should.equal(false)
inst.isType(null).should.equal(false)
inst.isType(NaN).should.equal(false)
Expand Down

0 comments on commit 067500b

Please sign in to comment.