Better handling of unions of literals/enums
Opened this issue · 1 comments
ForbesLindesay commented
It would be good to have a Runtype for Enum
that could take an existing TypeScript enum and return a type for validating it.
It would also be possible to optimise unions of literals by generating a Set<string | number>
up front to allow O(log(n))
lookup instead of linearly traversing the list. It might also be worth adding some form of caching to show
.
ForbesLindesay commented
It should be able to handle cases where unions are nested and cases where one entry in the union has multiple possible literal values for a tag