//#region src/utils/validation/validateArray.ts
/**
* Validates a email field.
* @param value The value to validate.
* @param entityName The name of the entity being validated.
* @param minLength The minimum length of the string.
* @param maxLength The maximum length of the string.
* @returns An array of validation errors.
*/
const validateArray = (value, entityName = "Array", elementType, elementValidator, minLength = 0, maxLength = void 0) => {
	const errors = [];
	if (!Array.isArray(value)) errors.push(`${entityName} must be an array.`);
	else if (minLength && value.length < minLength) errors.push(`${entityName} must be at least ${minLength} items long.`);
	else if (maxLength && value.length > maxLength) errors.push(`${entityName} must be at most ${maxLength} items long.`);
	else if (elementType) {
		if (!value.every((element) => {
			return typeof element === elementType;
		})) errors.push(`${entityName} must contain only ${elementType} elements.`);
	} else if (elementValidator) {
		const isValidOrErrorList = value.every(elementValidator);
		if (Array.isArray(isValidOrErrorList)) {
			if (!(isValidOrErrorList.length > 0)) errors.push(...isValidOrErrorList);
		} else if (!isValidOrErrorList) errors.push(`${entityName} must contain valid elements.`);
	}
	return errors;
};

//#endregion
export { validateArray };
//# sourceMappingURL=validateArray.mjs.map