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 | 1x 18x 18x 3x 15x 24x 1x 23x 1x 24x 1x | const isObject = require('lodash.isobject');
function validateValues(item, key) {
const values = item && item.values;
if (!Array.isArray(values)) {
return [];
}
return values.reduce((errors, value) => {
if (!isObject(value)) {
errors.push(new Error(`items inside values must be objects for key "${key}"`));
} else if (!Object.prototype.hasOwnProperty.call(value, 'value')) {
errors.push(new Error(`items inside values must have a value property for key "${key}"`));
}
return errors;
}, []);
}
module.exports = validateValues;
|