1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-04-19 01:17:18 +02:00
unleash.unleash/src/lib/features/export-import-toggles/import-context-validation.ts
2023-08-23 11:11:16 +02:00

19 lines
559 B
TypeScript

import { IContextFieldDto } from '../../types/stores/context-field-store';
export const isValidField = (
importedField: IContextFieldDto,
existingFields: IContextFieldDto[],
): boolean => {
const matchingExistingField = existingFields.find(
(field) => field.name === importedField.name,
);
if (!matchingExistingField) {
return true;
}
return (importedField.legalValues || []).every((value) =>
(matchingExistingField.legalValues || []).find(
(v) => v.value === value.value,
),
);
};