mirror of
https://github.com/Unleash/unleash.git
synced 2024-11-01 19:07:38 +01:00
17 lines
520 B
TypeScript
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),
|
|
);
|
|
};
|