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

17 lines
520 B
TypeScript
Raw Normal View History

import { IContextFieldDto } from '../../types/stores/context-field-store';
2023-02-16 08:08:51 +01:00
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),
);
};