I have a dataclass and enum values which are as below:
@dataclass
class my_class:
id: str
dataType: CheckTheseDataTypes
class CheckTheseDataTypes(str,Enum):
FIRST="int"
SECOND="float"
THIRD = "string"
I want to check whenever this dataclass is called it should have the datatype values only from the given enum list. I wrote an external validator initially like the below:
if datatype not in CheckTheseDataTypes.__members__:
I am actually looking for something where I don't need this external validation. Any help is much appreciated.