When making API calls from an API in typescript, I want to clarify how the response should look by using an interface. One particular value is a string that can only have specific values. Isn't this what enums are for?
The possible values are:
"Normal Goal", "Own Goal", "Penalty", "Missed Penalty",
"Yellow Card", "Second Yellow Card", "Red Card",
"Substitution x"
where x can be any positive integer. The challenge lies in implementing this. I attempted to use Regex, like so:
enum Event {
"Normal Goal", "Own Goal", "Penalty", "Missed Penalty",
"Yellow Card", "Second Yellow Card", "Red Card",
"Substitution [1-9]\d*$"
}
Unfortunately, this approach didn't work as expected. If this method proves impossible, I may have to change the enum to a string type. Do you have any alternative suggestions for achieving this?