I am looking for a way to create a generic type that verifies certain criteria on an enum:
- all fields must be strings
- all values must be equal to their respective keys
For example, the following enums would meet the requirements:
enum correct1 {
bar = 'bar',
baz = 'baz',
}
enum correct2 {
quux = 'quux',
}
However, the following enums would not:
enum wrongFoo {
bar = 'bar',
baz = 'WRONG',
}
enum wrongFoo2 {
bar = 1
}
Can you provide the correct syntax to achieve this validation?