1 Commits

Author SHA1 Message Date
root 0bfa3b32bd Merge pull request '[chore] bump version and changelog' (#18) from release/0.0.6 into develop
continuous-integration/drone/push Build is passing
Reviewed-on: #18
2020-07-04 14:36:05 +00:00
3 changed files with 13 additions and 19 deletions
-4
View File
@@ -1,9 +1,5 @@
# ChangeLog
## 2020-07-05 (0.0.7)
- fix array check contains type
## 2020-07-04 (0.0.6)
- add array validate contains type
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "mtfos-validator",
"version": "0.0.7",
"version": "0.0.6",
"description": "",
"main": "index.js",
"scripts": {
+12 -14
View File
@@ -61,22 +61,20 @@ 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}`
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
}
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