diff --git a/src/boolean.js b/src/boolean.js index 935b44143..aa9af89ea 100644 --- a/src/boolean.js +++ b/src/boolean.js @@ -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) } }) diff --git a/src/number.js b/src/number.js index 12f835b67..355076070 100644 --- a/src/number.js +++ b/src/number.js @@ -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) { diff --git a/test/bool.js b/test/bool.js index fef55bd3b..addc01c82 100644 --- a/test/bool.js +++ b/test/bool.js @@ -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) diff --git a/test/number.js b/test/number.js index 0897286d8..de5b47748 100644 --- a/test/number.js +++ b/test/number.js @@ -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)