So I am creating a parser to parse some configuration files made by our client engineers. I don't particularly trust our client engineers. They can usually spell things right but they can never remember what to capitalize. This makes Enum
classes kind of noisome in that they go and break the program cause the Enum
fails if they don't type in the exact right string.
Here is my Enum Class:
object EnumLayoutAlignment extends Enumeration
{
type Alignment = Value
val Vertical = Value("Vertical")
val Horizontal = Value("Horizontal")
}
Is there a way I could make it so that "Vertical", "vertical", and "VERTICAL" all mapped to the same enum value?
EDIT: @Radai brought up a good point of just .upper() on the input but I would also like to include "vert" and other similar inputs
I used this as an example