import { validateArray } from "./validateArray.mjs";
import { validateString } from "./validateString.mjs";

//#region src/utils/validation/validateOrganization.ts
const defaultFieldsToCheck = [
	"name",
	"membersIds",
	"adminsIds"
];
const NAME_MIN_LENGTH = 4;
const NAME_MAX_LENGTH = 100;
const MEMBERS_MIN_LENGTH = 1;
/**
* Validates an organization object.
* @param organization The organization object to validate.
* @returns An object containing the validation errors for each field.
*/
const validateOrganization = (organization, fieldsToCheck = defaultFieldsToCheck) => {
	const errors = {};
	const organizationObject = JSON.parse(JSON.stringify(organization));
	const fieldsToValidate = new Set(fieldsToCheck);
	for (const field of fieldsToValidate) {
		const value = organizationObject[field];
		errors[field] = [];
		if (field === "name") {
			const nameErrors = validateString(value, "Name", NAME_MIN_LENGTH, NAME_MAX_LENGTH);
			if (nameErrors.length > 0) errors[field] = nameErrors;
		}
		if (field === "membersIds" || field === "adminsIds") {
			const membersErrors = validateArray(value, "Members", "string", void 0, MEMBERS_MIN_LENGTH);
			if (membersErrors.length > 0) errors[field] = membersErrors;
		}
		if (errors[field].length === 0) delete errors[field];
	}
	return errors;
};

//#endregion
export { MEMBERS_MIN_LENGTH, NAME_MAX_LENGTH, NAME_MIN_LENGTH, validateOrganization };
//# sourceMappingURL=validateOrganization.mjs.map