I am making API calls from an API in typescript and I would like to clearify how the response looks like using an interface. One of its values is an string which can only have a (defined) number of values. In my opinion that is the what enums are for, right?
These are the possible values:
"Normal Goal", "Own Goal", "Penalty", "Missed Penalty",
"Yellow Card", "Second Yellow Card", "Red Card",
"Substitution x"
where x can be any positive integer. And this x is the problem...
To implement it I tried using Regex. This is what it looks like:
enum Event {
"Normal Goal", "Own Goal", "Penalty", "Missed Penalty",
"Yellow Card", "Second Yellow Card", "Red Card",
"Substitution [1-9]\d*$"
}
But it does not seem to work. If it isn't possible I'll just have to change the enum to type string but do you have any other idea how one could do this?