RestrictTuple

class ipkiss3.all.RestrictTuple

Restrict the value of the property to a tuple, with values of specified allowed types.

Parameters:
allowed_types: tuple of types, optional

A tuple (or list) of types (classes), if provided each value in the tuple should be an instance of one of the given types

Examples

import ipkiss3.all as i3

class Example(i3.StrongPropertyInitializer):

    num_prop = i3.DefinitionProperty(restriction=i3.RestrictTuple((str, int)))

example1 = Example(num_prop=(2, 3)) # this is ok
example2 = Example(num_prop=('hello', '2' , 'world')) # this is ok as well

example3 = Example(num_prop=(1.0, )) # this will fail
allowed_types