Skip to content

Commit 90e1033

Browse files
committed
String objects should be considered valid strings.
1 parent b84a0ae commit 90e1033

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

src/string.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ function StringSchema(){
2424
inherits(StringSchema, MixedSchema, {
2525

2626
_typeCheck(value) {
27-
return typeof value === 'string'
27+
return (typeof value === 'string') || (typeof value === 'object' && value instanceof String)
2828
},
2929

3030
required(msg){
@@ -99,4 +99,4 @@ inherits(StringSchema, MixedSchema, {
9999
test: val => val == null || val === val.toUpperCase()
100100
})
101101
}
102-
})
102+
})

test/string.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ describe('String types', function(){
5252
var inst = string()
5353

5454
inst.isType('5').should.equal(true)
55+
inst.isType(new String('5')).should.equal(true)
5556
inst.isType(false).should.equal(false)
5657
inst.isType(null).should.equal(false)
5758
inst.nullable(false).isType(null).should.equal(false)
@@ -135,4 +136,4 @@ describe('String types', function(){
135136
.should.eventually.equal(false)
136137
])
137138
})
138-
})
139+
})

0 commit comments

Comments
 (0)