1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-11-01 19:07:38 +01:00
unleash.unleash/src/lib/features/export-import-toggles/import-context-validation.ts
2023-02-21 10:15:57 +01:00

17 lines
520 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),
);
};