Uname: Linux webm016.cluster127.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 7.4.33 [ PHP INFO ] PHP os: Linux
Server Ip: 54.36.31.145
Your Ip: 216.73.216.182
User: homesquasz (91404) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : validateObjectWithArrayProps.js
'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((array) => {
		if (!Array.isArray(array)) {
			return false;
		}

		// Make sure the array items are strings
		return array.every((item) => {
			if (Array.isArray(validator)) {
				return validator.some((v) => v(item));
			}

			return validator(item);
		});
	});
};
© 2026 GrazzMean