Closed olivierbeaulieu closed 2 years ago
The example makes no sense to me. Why would you ever accept string if what you actually want is to accept an enum value? Do you maybe have a more realistic example?
In general, I'm lukewarm to adding support for anything regarding TypeScript enums, as they suck. I love enums in other languages, but the TS one is just bad. More on that.
I see what you mean - maybe I need to clarify a couple things.
Alright. I'm going to accept this.
The check should be Object.values(Enum).includes(case)
.
I also think is.enumCase
may be a better name as you're checking the case, not the whole enum itself.
Hello!
I've been wondering whether
is
could help me validate that astring
is a member of a specific enum - I haven't found anything in the library that does that, so I wanted to ask whether that would be a good addition.Here's what I'm hoping to achieve:
This obviously would not work for const enums - but could be very handy for the rest. Happy to contribute if the proposition makes sense.