RestrictFunction

class ipkiss3.all.RestrictFunction

restricts the value to those that return ‘True’ when passed to a given function

Parameters:
validator_function: callable

A function or callable that returns a bool to validate the passed value.

Examples

import ipkiss3.all as i3

def is_even(val):
    return (val % 2) == 0

class Example(i3.StrongPropertyInitializer):

    num_prop = i3.DefinitionProperty(restriction=i3.RestrictFunction(is_even))

example1 = Example(num_prop=2) # this is ok
example2 = Example(num_prop=1) # this will fail
validator_function