[fix] check contains type
This commit is contained in:
parent
b684a0e35e
commit
b282f241a6
@ -61,20 +61,22 @@ class TypeArray extends Base {
|
||||
if (this._min !== null && value.length < this._min) return `value length < ${this._min}`
|
||||
if (this._max !== null && value.length > this._max) return `value length > ${this._max}`
|
||||
|
||||
for (const item of value) {
|
||||
let verified = false
|
||||
let fail = ''
|
||||
for (const type of this._itemTypes) {
|
||||
const result = type.validate(item)
|
||||
if (result) {
|
||||
fail = result
|
||||
} else {
|
||||
verified = true
|
||||
fail = ''
|
||||
break
|
||||
if (this._itemTypes.length > 0) {
|
||||
for (const item of value) {
|
||||
let verified = false
|
||||
let fail = ''
|
||||
for (const type of this._itemTypes) {
|
||||
const result = type.validate(item)
|
||||
if (result) {
|
||||
fail = result
|
||||
} else {
|
||||
verified = true
|
||||
fail = ''
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!verified || fail) return fail || `item type not match`
|
||||
}
|
||||
if (!verified || fail) return fail || `item type not match`
|
||||
}
|
||||
|
||||
return null
|
||||
|
Loading…
Reference in New Issue
Block a user