RestrictValueEnum¶
- class ipkiss3.all.RestrictValueEnum(allowed_values)¶
restrict the argument to the members of an Enum. The value should actually be an Enum item, not a value with the same value as an Enum item
- Parameters
- allowed_values: Enum
An Enum of allowed values
Examples
from ipkiss.all import * class Color(Enum): purple = 1 violet = 2 indigo = 3 class Example(StrongPropertyInitializer): num_prop = DefinitionProperty(restriction=RestrictValueEnum(Color)) example1 = Example(num_prop=Color.purple) # this is ok example2 = Example(num_prop=1) # this will fail
- allowed_values¶