const convertPartyTypeStringToEnum = (partyType: string): EPartyType => {
switch (partyType.toUpperCase()) {
case EPartyType.GROUP:
return EPartyType.GROUP;
case EPartyType.PERSON:
return EPartyType.PERSON;
default:
throw new Error('Wrong party type string, expect one of EPartyType');
}
};
`export function isInEnum<E>(value: any, enumeration: E): value is E[keyof E] { return Object.values(enumeration).includes(value as E[keyof E]); }`
Обсуждают сегодня