enumValidator

function enumValidator<T>(enumMap): (x) => x is Object extends T ? never : T[keyof T]

Creates a validator which tests if the target is a value in the specified enum.
Note that numbers in enums are reverse-mapped by the TS transpiler, so the specified keys are also values.

Type parameters

Type parameter
T

Parameters

ParameterType
enumMapT

Returns

Function

Parameters

ParameterType
xunknown

Returns

x is Object extends T ? never : T[keyof T]