Skip to content

Commit 067500b

Browse files
committed
Number and Boolean instances should be considered valid.
1 parent 90e1033 commit 067500b

File tree

4 files changed

+7
-2
lines changed

4 files changed

+7
-2
lines changed

src/boolean.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function BooleanSchema(){
1919
inherits(BooleanSchema, MixedSchema, {
2020

2121
_typeCheck(v){
22-
return typeof v === 'boolean'
22+
return (typeof v === 'boolean') || (typeof v === 'object' && v instanceof Boolean)
2323
}
2424
})
2525

src/number.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ function NumberSchema(){
2222
inherits(NumberSchema, SchemaObject, {
2323

2424
_typeCheck(v) {
25-
return typeof v === 'number' && !(v !== +v) //isNaN check
25+
if ( typeof v === 'number' && !(v !== +v) ) return true
26+
if ( typeof v === 'object' && v instanceof Number ) return true
27+
28+
return false
2629
},
2730

2831
min(min, msg) {

test/bool.js

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ describe('Boolean types', function(){
4040
inst.isType('true').should.equal(false)
4141
inst.isType(NaN).should.equal(false)
4242
inst.isType(34545).should.equal(false)
43+
inst.isType(new Boolean(false)).should.equal(true)
4344
chai.expect(
4445
inst.isType(null)).to.equal(false)
4546
inst.nullable().isType(null).should.equal(true)

test/number.js

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ describe('Number types', function(){
4848
var inst = number()
4949

5050
inst.isType(5).should.equal(true)
51+
inst.isType(new Number(5)).should.equal(true)
5152
inst.isType(false).should.equal(false)
5253
inst.isType(null).should.equal(false)
5354
inst.isType(NaN).should.equal(false)

0 commit comments

Comments
 (0)