This question Check if value exists in enum in TypeScript has several answers that do not work for string enums (or some say they do but others don't). It's more work than it should be to sort through those answers so another question will help people sort this out in the future.
Let's say I have a query string value that must be a type of Vehicle. I have this enum:
export enum VehicleTypes {
Car = 'car',
Bike = 'bike',
Skateboard = 'skateboard',
}
How do I verify that a string is one of the values in that enum?
if (! [...some logic here]) return response.code(400).send(`invalid vehicle type ${vehicle}`);