fix: apply feedback

This commit is contained in:
yassinedorbozgithub 2025-06-10 18:19:38 +01:00
parent f4ca6613c7
commit bac3597614

View File

@ -9,13 +9,5 @@
export const validateUniqueFields = <T>(
fields: T[],
fieldName: keyof T,
): boolean => {
if (!Array.isArray(fields)) return false;
const seen = new Set<string>();
return fields.every((f) => {
const fieldValue = f[fieldName] as string;
if (seen.has(fieldValue)) return false;
seen.add(fieldValue);
return true;
});
};
): boolean =>
new Set(fields.map((f) => f[fieldName] as string)).size === fields.length;