isEnum should also accept an enumeration object
Opened this issue · 0 comments
lazarljubenovic commented
Instead of writing
export const isLanguageCode = tg.isEnum(...enumValues(LanguageCode))
where enumValues
is a function defied as follows
export function enumValues<T extends object> (enumeration: T): Array<T[keyof T]> {
return objectKeys(enumeration)
.filter(k => isNaN(Number(k)))
.map(k => enumeration[k])
}
allow the consumer to simply write
export const isLanguageCode = tg.isEnum(LanguageCode)
Maybe deprecate listing all values and create a new guard for that?