Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 1x 1x 1x 18x 18x 18x 4x 14x 64x 14x 1x | const isObject = require('lodash.isobject');
const isEmpty = require('lodash.isempty');
const validateValuesByRule = require('./validate-values-by-rule');
function validateValuesByRules(rules, item, key) {
const errors = [];
const values = isObject(item) && item.values;
if (
!Array.isArray(values)
|| isEmpty(values)
|| !Array.isArray(rules)
|| isEmpty(rules)
) {
return errors;
}
rules.forEach((rule) => {
errors.push(...validateValuesByRule(key, values, rule));
});
return errors;
}
module.exports = validateValuesByRules;
|