RestrictValueEnum

class ipkiss3.all.RestrictValueEnum

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

import ipkiss3.all as i3

class Color(Enum):
    purple = 1
    violet = 2
    indigo = 3

class Example(i3.StrongPropertyInitializer):

    num_prop = i3.DefinitionProperty(restriction=i3.RestrictValueEnum(Color))

example1 = Example(num_prop=Color.purple) # this is ok
example2 = Example(num_prop=1) # this will fail
allowed_values