validno 0.2.1 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ValidnoResult.js +80 -0
- package/dist/dev.js +87 -101
- package/dist/utils/helpers.js +48 -0
- package/dist/utils/nested.js +1 -0
- package/dist/validate.js +73 -113
- package/package.json +1 -1
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import _errors from "./utils/errors.js";
|
|
2
|
+
class ValidnoResult {
|
|
3
|
+
constructor(results) {
|
|
4
|
+
this.ok = (results === null || results === void 0 ? void 0 : results.ok) !== undefined ? results.ok : null;
|
|
5
|
+
this.missed = (results === null || results === void 0 ? void 0 : results.missed) || [];
|
|
6
|
+
this.failed = (results === null || results === void 0 ? void 0 : results.failed) || [];
|
|
7
|
+
this.passed = (results === null || results === void 0 ? void 0 : results.passed) || [];
|
|
8
|
+
this.errors = (results === null || results === void 0 ? void 0 : results.errors) || [];
|
|
9
|
+
this.byKeys = (results === null || results === void 0 ? void 0 : results.byKeys) || {};
|
|
10
|
+
this.errorsByKeys = (results === null || results === void 0 ? void 0 : results.errorsByKeys) || {};
|
|
11
|
+
this.byKeys = (results === null || results === void 0 ? void 0 : results.byKeys) || {};
|
|
12
|
+
}
|
|
13
|
+
setKeyStatus(key, result) {
|
|
14
|
+
this.byKeys[key] = result;
|
|
15
|
+
}
|
|
16
|
+
fixParentByChilds(parentKey, childChecks = []) {
|
|
17
|
+
const isEveryOk = childChecks.every(c => c === true);
|
|
18
|
+
this.setKeyStatus(parentKey, isEveryOk);
|
|
19
|
+
if (isEveryOk === true)
|
|
20
|
+
this.setPassed(parentKey);
|
|
21
|
+
else
|
|
22
|
+
this.setFailed(parentKey);
|
|
23
|
+
}
|
|
24
|
+
setMissing(key, errMsg) {
|
|
25
|
+
const error = errMsg || _errors.getMissingError(key);
|
|
26
|
+
this.missed.push(key);
|
|
27
|
+
this.setFailed(key, error);
|
|
28
|
+
this.setKeyStatus(key, false);
|
|
29
|
+
}
|
|
30
|
+
setPassed(key) {
|
|
31
|
+
this.passed.push(key);
|
|
32
|
+
this.setKeyStatus(key, true);
|
|
33
|
+
}
|
|
34
|
+
setFailed(key, msg) {
|
|
35
|
+
if (key in this.errorsByKeys === false) {
|
|
36
|
+
this.errorsByKeys[key] = [];
|
|
37
|
+
}
|
|
38
|
+
this.failed.push(key);
|
|
39
|
+
this.setKeyStatus(key, false);
|
|
40
|
+
if (!msg)
|
|
41
|
+
return;
|
|
42
|
+
this.errors.push(msg);
|
|
43
|
+
this.errorsByKeys[key].push(msg);
|
|
44
|
+
}
|
|
45
|
+
joinErrors(separator = '; ') {
|
|
46
|
+
return _errors.joinErrors(this.errors, separator);
|
|
47
|
+
}
|
|
48
|
+
merge(resultsNew) {
|
|
49
|
+
this.failed = [...this.failed, ...resultsNew.failed];
|
|
50
|
+
this.errors = [...this.errors, ...resultsNew.errors];
|
|
51
|
+
this.missed = [...this.missed, ...resultsNew.missed];
|
|
52
|
+
this.passed = [...this.passed, ...resultsNew.passed];
|
|
53
|
+
this.byKeys = Object.assign(Object.assign({}, this.byKeys), resultsNew.byKeys);
|
|
54
|
+
for (const key in resultsNew.errorsByKeys) {
|
|
55
|
+
if (key in this.errorsByKeys === false)
|
|
56
|
+
this.errorsByKeys[key] = [];
|
|
57
|
+
this.errorsByKeys[key] = [
|
|
58
|
+
...this.errorsByKeys[key],
|
|
59
|
+
...resultsNew.errorsByKeys[key]
|
|
60
|
+
];
|
|
61
|
+
}
|
|
62
|
+
return this;
|
|
63
|
+
}
|
|
64
|
+
clearEmptyErrorsByKeys() {
|
|
65
|
+
for (const key in this.errorsByKeys) {
|
|
66
|
+
if (!this.errorsByKeys[key].length) {
|
|
67
|
+
delete this.errorsByKeys[key];
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
finish() {
|
|
72
|
+
if (this.failed.length)
|
|
73
|
+
this.ok = false;
|
|
74
|
+
else
|
|
75
|
+
this.ok = true;
|
|
76
|
+
this.clearEmptyErrorsByKeys();
|
|
77
|
+
return this;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export default ValidnoResult;
|
package/dist/dev.js
CHANGED
|
@@ -1,105 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
if (TYPES.includes('array'))
|
|
48
|
-
listSame.push(() => ['true', 'true', 'false', 'true', 'false']);
|
|
49
|
-
i++;
|
|
50
|
-
}
|
|
51
|
-
console.timeEnd('autofill');
|
|
52
|
-
const compareArrs = (v1, v2) => {
|
|
53
|
-
if (v1.length !== v2.length)
|
|
54
|
-
return false;
|
|
55
|
-
return v1.every((el, i) => {
|
|
56
|
-
if (_validations.isObject(el)) {
|
|
57
|
-
return JSON.stringify(el) === JSON.stringify(v2[i]);
|
|
58
|
-
}
|
|
59
|
-
return v2[i] === el;
|
|
1
|
+
import { Schema } from "./Schema.js";
|
|
2
|
+
const validateConfig = (cfg) => {
|
|
3
|
+
const cfgSchema = new Schema({
|
|
4
|
+
methods: {
|
|
5
|
+
create: {
|
|
6
|
+
type: Object,
|
|
7
|
+
required: false,
|
|
8
|
+
},
|
|
9
|
+
createMany: {
|
|
10
|
+
type: Object,
|
|
11
|
+
required: false,
|
|
12
|
+
},
|
|
13
|
+
get: {
|
|
14
|
+
type: Object,
|
|
15
|
+
required: false,
|
|
16
|
+
},
|
|
17
|
+
getAll: {
|
|
18
|
+
type: Object,
|
|
19
|
+
required: false,
|
|
20
|
+
},
|
|
21
|
+
update: {
|
|
22
|
+
type: Object,
|
|
23
|
+
required: false,
|
|
24
|
+
},
|
|
25
|
+
delete: {
|
|
26
|
+
type: Object,
|
|
27
|
+
required: false,
|
|
28
|
+
},
|
|
29
|
+
deleteMany: {
|
|
30
|
+
type: Object,
|
|
31
|
+
required: false,
|
|
32
|
+
},
|
|
33
|
+
export: {
|
|
34
|
+
type: Object,
|
|
35
|
+
required: false,
|
|
36
|
+
},
|
|
37
|
+
distinct: {
|
|
38
|
+
type: Object,
|
|
39
|
+
required: false,
|
|
40
|
+
},
|
|
41
|
+
custom: {
|
|
42
|
+
type: Array,
|
|
43
|
+
required: false,
|
|
44
|
+
rules: {},
|
|
45
|
+
},
|
|
46
|
+
},
|
|
60
47
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const bothArrays = _validations.isArray(value) && _validations.isArray(compareTo);
|
|
67
|
-
if (bothArrays) {
|
|
68
|
-
return compareArrs(value, compareTo);
|
|
69
|
-
}
|
|
70
|
-
const bothObjects = _validations.isObject(value) && _validations.isObject(compareTo);
|
|
71
|
-
if (bothObjects) {
|
|
72
|
-
const valueStr = JSON.stringify(value);
|
|
73
|
-
const compareToStr = JSON.stringify(compareTo);
|
|
74
|
-
return valueStr === compareToStr;
|
|
48
|
+
const res = cfgSchema.validate(cfg);
|
|
49
|
+
console.log(res);
|
|
50
|
+
if (res.ok !== true) {
|
|
51
|
+
const errorsMsg = res.errors.join('; ');
|
|
52
|
+
throw new Error(errorsMsg);
|
|
75
53
|
}
|
|
76
|
-
const bothDates = _validations.isDate(value) && _validations.isDate(compareTo);
|
|
77
|
-
if (bothDates) {
|
|
78
|
-
return value.getTime() === compareTo.getTime();
|
|
79
|
-
}
|
|
80
|
-
return value === compareTo;
|
|
81
|
-
};
|
|
82
|
-
const is2 = (value, compareTo) => {
|
|
83
|
-
return true;
|
|
84
54
|
};
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
55
|
+
const uniTestService = {
|
|
56
|
+
methods: {
|
|
57
|
+
getAll: {
|
|
58
|
+
isActive: true,
|
|
59
|
+
sort: {
|
|
60
|
+
default: 'createdAt',
|
|
61
|
+
},
|
|
62
|
+
search: {
|
|
63
|
+
fields: ['title'],
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
export: {
|
|
67
|
+
isActive: false,
|
|
68
|
+
},
|
|
69
|
+
get: {
|
|
70
|
+
isActive: true,
|
|
71
|
+
},
|
|
72
|
+
create: null,
|
|
73
|
+
createMany: {
|
|
74
|
+
isActive: true,
|
|
75
|
+
},
|
|
76
|
+
update: {
|
|
77
|
+
isActive: true,
|
|
78
|
+
},
|
|
79
|
+
delete: {
|
|
80
|
+
isActive: true,
|
|
81
|
+
},
|
|
82
|
+
deleteMany: {
|
|
83
|
+
isActive: true,
|
|
84
|
+
},
|
|
85
|
+
distinct: {
|
|
86
|
+
isActive: true,
|
|
87
|
+
fields: ['title', '_id'],
|
|
88
|
+
},
|
|
89
|
+
},
|
|
103
90
|
};
|
|
104
|
-
|
|
105
|
-
doTest(is3);
|
|
91
|
+
validateConfig(uniTestService);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { defaultSchemaKeys } from "../Schema.js";
|
|
2
|
+
import ValidnoResult from "../ValidnoResult.js";
|
|
3
|
+
import _validations from "./validations.js";
|
|
4
|
+
const _helpers = {};
|
|
5
|
+
_helpers.checkIsNested = (obj) => {
|
|
6
|
+
if (!_validations.isObject(obj))
|
|
7
|
+
return false;
|
|
8
|
+
const objKeys = Object.keys(obj);
|
|
9
|
+
if (objKeys.every((k) => defaultSchemaKeys.includes(k))) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
_helpers.mergeResults = (resultsOld, resultsNew) => {
|
|
17
|
+
const output = new ValidnoResult();
|
|
18
|
+
output.failed = [...resultsOld.failed, ...resultsNew.failed];
|
|
19
|
+
output.errors = [...resultsOld.errors, ...resultsNew.errors];
|
|
20
|
+
output.missed = [...resultsOld.missed, ...resultsNew.missed];
|
|
21
|
+
output.passed = [...resultsOld.passed, ...resultsNew.passed];
|
|
22
|
+
output.byKeys = Object.assign(Object.assign({}, resultsOld.byKeys), resultsNew.byKeys);
|
|
23
|
+
output.errorsByKeys = Object.assign(Object.assign({}, resultsOld.errorsByKeys), resultsNew.errorsByKeys);
|
|
24
|
+
return output;
|
|
25
|
+
};
|
|
26
|
+
_helpers.checkNestedIsMissing = (reqs, data) => {
|
|
27
|
+
const isRequired = reqs.required;
|
|
28
|
+
const isUndef = data === undefined;
|
|
29
|
+
const isEmpty = _validations.isObject(data) && !Object.keys(data).length;
|
|
30
|
+
return isRequired && (isUndef || isEmpty);
|
|
31
|
+
};
|
|
32
|
+
_helpers.areKeysLimited = (onlyKeys) => {
|
|
33
|
+
const hasArrayOfKeys = (Array.isArray(onlyKeys) && onlyKeys.length > 0);
|
|
34
|
+
const hasStringKey = (typeof onlyKeys === 'string' && onlyKeys.length > 0);
|
|
35
|
+
return hasArrayOfKeys || hasStringKey;
|
|
36
|
+
};
|
|
37
|
+
_helpers.needValidation = (key, hasLimits, onlyKeys) => {
|
|
38
|
+
const noLimits = !hasLimits;
|
|
39
|
+
const keyIsInList = (key === onlyKeys || Array.isArray(onlyKeys) && (onlyKeys === null || onlyKeys === void 0 ? void 0 : onlyKeys.includes(key)));
|
|
40
|
+
return noLimits || keyIsInList;
|
|
41
|
+
};
|
|
42
|
+
_helpers.hasMissing = (input) => {
|
|
43
|
+
const { reqs, data, key } = input;
|
|
44
|
+
const isRequired = reqs.required === true;
|
|
45
|
+
const missingData = (data === undefined || key in data === false || data[key] === undefined);
|
|
46
|
+
return isRequired && missingData;
|
|
47
|
+
};
|
|
48
|
+
export default _helpers;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/dist/validate.js
CHANGED
|
@@ -1,89 +1,69 @@
|
|
|
1
1
|
import checkType from "./checkType.js";
|
|
2
2
|
import _errors from "./utils/errors.js";
|
|
3
3
|
import checkRules from "./checkRules.js";
|
|
4
|
-
import
|
|
4
|
+
import _helpers from "./utils/helpers.js";
|
|
5
5
|
import { ErrorKeywords } from "./constants/details.js";
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
const objKeys = Object.keys(obj);
|
|
22
|
-
if (objKeys.every((k) => defaultSchemaKeys.includes(k))) {
|
|
23
|
-
return false;
|
|
6
|
+
import ValidnoResult from "./ValidnoResult.js";
|
|
7
|
+
function generateMsg(input) {
|
|
8
|
+
let { results, key, deepKey, data, reqs } = input;
|
|
9
|
+
const keyForMsg = deepKey || key;
|
|
10
|
+
const keyTitle = 'title' in reqs ? reqs.title : keyForMsg;
|
|
11
|
+
if (reqs.customMessage && typeof reqs.customMessage === 'function') {
|
|
12
|
+
const errMsg = reqs.customMessage({
|
|
13
|
+
keyword: ErrorKeywords.Missing,
|
|
14
|
+
value: data[key],
|
|
15
|
+
key: keyForMsg,
|
|
16
|
+
title: keyTitle,
|
|
17
|
+
reqs: reqs,
|
|
18
|
+
schema: this.schema
|
|
19
|
+
});
|
|
20
|
+
return errMsg;
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
return _errors.getMissingError(keyForMsg);
|
|
23
|
+
}
|
|
24
|
+
function handleDeepKey(input) {
|
|
25
|
+
const { results, key, deepKey, data, reqs } = input;
|
|
26
|
+
const nesctedKeys = Object.keys(reqs);
|
|
27
|
+
const nestedResults = [];
|
|
28
|
+
let i = 0;
|
|
29
|
+
while (i < nesctedKeys.length) {
|
|
30
|
+
const nestedKey = nesctedKeys[i];
|
|
31
|
+
const deepParams = {
|
|
32
|
+
key: nestedKey,
|
|
33
|
+
data: data[key],
|
|
34
|
+
reqs: reqs[nestedKey],
|
|
35
|
+
deepKey: `${deepKey}.${nestedKey}`
|
|
36
|
+
};
|
|
37
|
+
const deepResults = handleKey.call(this, deepParams);
|
|
38
|
+
nestedResults.push(deepResults.ok);
|
|
39
|
+
results.merge(deepResults);
|
|
40
|
+
i++;
|
|
27
41
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
export function handleReqKey(key, data, reqs, deepKey = key) {
|
|
40
|
-
let results = getResultDefaults();
|
|
41
|
-
const hasNested = checkIsNested(reqs);
|
|
42
|
-
const keyTitle = 'title' in reqs ? reqs.title : deepKey;
|
|
42
|
+
results.fixParentByChilds(deepKey, nestedResults);
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
export function handleKey(input) {
|
|
46
|
+
let { results, key, deepKey, data, reqs } = input;
|
|
47
|
+
if (!results)
|
|
48
|
+
results = new ValidnoResult();
|
|
49
|
+
if (!deepKey)
|
|
50
|
+
deepKey = key;
|
|
51
|
+
const hasNested = _helpers.checkIsNested(reqs);
|
|
52
|
+
const hasMissing = _helpers.hasMissing(input);
|
|
43
53
|
const missedCheck = [];
|
|
44
54
|
const typeChecked = [];
|
|
45
55
|
const rulesChecked = [];
|
|
46
|
-
if (reqs
|
|
47
|
-
|
|
48
|
-
results.missed.push(deepKey);
|
|
49
|
-
results.failed.push(deepKey);
|
|
50
|
-
results.byKeys[deepKey] = false;
|
|
56
|
+
if (_helpers.checkNestedIsMissing(reqs, data)) {
|
|
57
|
+
results.setMissing(deepKey);
|
|
51
58
|
return results;
|
|
52
59
|
}
|
|
53
60
|
if (hasNested) {
|
|
54
|
-
|
|
55
|
-
results.byKeys[deepKey] = true;
|
|
56
|
-
let i = 0;
|
|
57
|
-
while (i < nestedReqKeys.length) {
|
|
58
|
-
const reqKeyI = nestedReqKeys[i];
|
|
59
|
-
const deepResults = handleReqKey.call(this, reqKeyI, data[key], reqs[reqKeyI], deepKey + '.' + reqKeyI);
|
|
60
|
-
results = mergeResults(results, deepResults);
|
|
61
|
-
i++;
|
|
62
|
-
}
|
|
63
|
-
return results;
|
|
61
|
+
return handleDeepKey.call(this, { results, key, data, reqs, deepKey });
|
|
64
62
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
console.log(data);
|
|
68
|
-
let errMsg = _errors.getMissingError(deepKey);
|
|
69
|
-
if (reqs.customMessage && typeof reqs.customMessage === 'function') {
|
|
70
|
-
errMsg = reqs.customMessage({
|
|
71
|
-
keyword: ErrorKeywords.Missing,
|
|
72
|
-
value: data[key],
|
|
73
|
-
key: deepKey,
|
|
74
|
-
title: keyTitle,
|
|
75
|
-
reqs: reqs,
|
|
76
|
-
schema: this.schema
|
|
77
|
-
});
|
|
78
|
-
}
|
|
63
|
+
if (hasMissing) {
|
|
64
|
+
let errMsg = generateMsg.call(this, input);
|
|
79
65
|
missedCheck.push(false);
|
|
80
|
-
results.
|
|
81
|
-
results.failed.push(deepKey);
|
|
82
|
-
results.errors.push(errMsg);
|
|
83
|
-
if (deepKey in results.errorsByKeys === false)
|
|
84
|
-
results.errorsByKeys[deepKey] = [];
|
|
85
|
-
results.errorsByKeys[deepKey].push(errMsg);
|
|
86
|
-
results.byKeys[deepKey] = false;
|
|
66
|
+
results.setMissing(deepKey, errMsg);
|
|
87
67
|
return results;
|
|
88
68
|
}
|
|
89
69
|
const typeCheck = checkType(key, data[key], reqs, deepKey);
|
|
@@ -104,52 +84,32 @@ export function handleReqKey(key, data, reqs, deepKey = key) {
|
|
|
104
84
|
});
|
|
105
85
|
}
|
|
106
86
|
if (missedCheck.length)
|
|
107
|
-
results.
|
|
108
|
-
|
|
109
|
-
|
|
87
|
+
results.setMissing(deepKey);
|
|
88
|
+
const isPassed = (!typeChecked.length && !rulesChecked.length && !missedCheck.length);
|
|
89
|
+
if (!isPassed) {
|
|
90
|
+
results.setFailed(deepKey);
|
|
91
|
+
results.errorsByKeys[deepKey] = [
|
|
92
|
+
...results.errors
|
|
93
|
+
];
|
|
110
94
|
}
|
|
111
95
|
else {
|
|
112
|
-
results.
|
|
96
|
+
results.setPassed(deepKey);
|
|
113
97
|
}
|
|
114
|
-
results.
|
|
115
|
-
...results.errors
|
|
116
|
-
];
|
|
117
|
-
results.byKeys[deepKey] = (missedCheck.length + typeChecked.length + rulesChecked.length) === 0;
|
|
118
|
-
return results;
|
|
98
|
+
return results.finish();
|
|
119
99
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
results = mergeResults(results, keyResult);
|
|
131
|
-
}
|
|
100
|
+
function validate(schema, data, keysToCheck) {
|
|
101
|
+
const results = new ValidnoResult();
|
|
102
|
+
const hasKeysToCheck = _helpers.areKeysLimited(keysToCheck);
|
|
103
|
+
const schemaKeys = Object.entries(schema.schema);
|
|
104
|
+
for (const [key, reqs] of schemaKeys) {
|
|
105
|
+
const toBeValidated = _helpers.needValidation(key, hasKeysToCheck, keysToCheck);
|
|
106
|
+
if (!toBeValidated)
|
|
107
|
+
continue;
|
|
108
|
+
const keyResult = handleKey.call(this, { key, data, reqs });
|
|
109
|
+
results.merge(keyResult);
|
|
132
110
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
else
|
|
136
|
-
results.ok = true;
|
|
137
|
-
return new ValidnoResult(results);
|
|
111
|
+
results.finish();
|
|
112
|
+
return results;
|
|
138
113
|
}
|
|
139
114
|
;
|
|
140
|
-
class ValidnoResult {
|
|
141
|
-
constructor(results) {
|
|
142
|
-
this.ok = results.ok;
|
|
143
|
-
this.missed = results.missed;
|
|
144
|
-
this.failed = results.failed;
|
|
145
|
-
this.passed = results.passed;
|
|
146
|
-
this.errors = results.errors;
|
|
147
|
-
this.byKeys = results.byKeys;
|
|
148
|
-
this.errorsByKeys = results.errorsByKeys;
|
|
149
|
-
this.byKeys = results.byKeys;
|
|
150
|
-
}
|
|
151
|
-
joinErrors(separator = '; ') {
|
|
152
|
-
return _errors.joinErrors(this.errors, separator);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
115
|
export default validate;
|