Sha256: d125d1d5963544da1aca12784f1c9200d9e9c08e2721011602cb4988a699dd89
Contents?: true
Size: 898 Bytes
Versions: 23
Compression:
Stored size: 898 Bytes
Contents
'use strict'; const _ = require('lodash'); /** * @template T * @typedef {(i: T) => boolean} Validator */ /** * Check whether the variable is an object and all it's properties are arrays of string values: * * ignoreProperties = { * value1: ["item11", "item12", "item13"], * value2: ["item21", "item22", "item23"], * value3: ["item31", "item32", "item33"], * } * @template T * @param {Validator<T>|Validator<T>[]} validator * @returns {(value: {[k: any]: T|T[]}) => boolean} */ module.exports = (validator) => (value) => { if (!_.isPlainObject(value)) { return false; } return Object.values(value).every((value) => { if (!Array.isArray(value)) { return false; } // Make sure the array items are strings return value.every((item) => { if (Array.isArray(validator)) { return validator.some((v) => v(item)); } return validator(item); }); }); };
Version data entries
23 entries across 23 versions & 1 rubygems