hotfix/array-check-contains-type #20
@ -61,20 +61,22 @@ class TypeArray extends Base {
|
|||||||
if (this._min !== null && value.length < this._min) return `value length < ${this._min}`
|
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}`
|
if (this._max !== null && value.length > this._max) return `value length > ${this._max}`
|
||||||
|
|
||||||
for (const item of value) {
|
if (this._itemTypes.length > 0) {
|
||||||
let verified = false
|
for (const item of value) {
|
||||||
let fail = ''
|
let verified = false
|
||||||
for (const type of this._itemTypes) {
|
let fail = ''
|
||||||
const result = type.validate(item)
|
for (const type of this._itemTypes) {
|
||||||
if (result) {
|
const result = type.validate(item)
|
||||||
fail = result
|
if (result) {
|
||||||
} else {
|
fail = result
|
||||||
verified = true
|
} else {
|
||||||
fail = ''
|
verified = true
|
||||||
break
|
fail = ''
|
||||||
|
break
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
if (!verified || fail) return fail || `item type not match`
|
||||||
}
|
}
|
||||||
if (!verified || fail) return fail || `item type not match`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null
|
return null
|
||||||
|
Loading…
Reference in New Issue
Block a user