Compare commits

...

9 Commits

Author SHA1 Message Date
Jay
c767e73f0a Merge pull request 'hotfix/array-check-contains-type' (#20) from hotfix/array-check-contains-type into develop
All checks were successful
continuous-integration/drone/push Build is passing
Reviewed-on: #20
2020-07-05 05:31:07 +00:00
Jay
7d8256a6d6 bump version and changelog
All checks were successful
continuous-integration/drone/push Build is passing
2020-07-05 05:29:53 +00:00
Jay
b282f241a6 [fix] check contains type 2020-07-05 05:29:39 +00:00
Jay
b684a0e35e Merge pull request 'release/0.0.6' (#17) from release/0.0.6 into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
Reviewed-on: #17
2020-07-04 14:35:49 +00:00
Jay
8645d9914b Merge pull request 'release/0.0.5' (#14) from release/0.0.5 into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-06-11 15:07:49 +00:00
Jay
057466c952 Merge pull request 'release/0.0.4' (#11) from release/0.0.4 into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-06-11 14:52:52 +00:00
Jay
564578c160 Merge pull request 'release/0.0.3' (#8) from release/0.0.3 into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-06-10 14:21:12 +00:00
Jay
e399cb0e30 Merge pull request 'release/0.0.2' (#5) from release/0.0.2 into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-06-10 13:39:05 +00:00
Jay
6fe8069868 Merge pull request 'Release v0.0.1' (#2) from release/v0.0.1 into master
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-06-03 15:58:51 +00:00
3 changed files with 19 additions and 13 deletions

View File

@ -1,5 +1,9 @@
# ChangeLog
## 2020-07-05 (0.0.7)
- fix array check contains type
## 2020-07-04 (0.0.6)
- add array validate contains type

View File

@ -1,6 +1,6 @@
{
"name": "mtfos-validator",
"version": "0.0.6",
"version": "0.0.7",
"description": "",
"main": "index.js",
"scripts": {

View File

@ -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