Skip to content

Validators

is_validator(function)

Determines whether the given function is an validator function or not. This is simply based on the existance of the is_validator attribute which is set in the decorator above.

Parameters:

Name Type Description Default
function

the function to check

required

Returns:

Type Description

True if the function is an validator function, False if not

Source code in ckantools/decorators/validators.py
13
14
15
16
17
18
19
20
21
22
def is_validator(function):
    """
    Determines whether the given function is an validator function or not. This is
    simply based on the existance of the is_validator attribute which is set in the
    decorator above.

    :param function: the function to check
    :return: True if the function is an validator function, False if not
    """
    return getattr(function, 'is_validator', False)

validator(function)

Decorator that indicates that the function being decorated is a validator function.

Source code in ckantools/decorators/validators.py
 5
 6
 7
 8
 9
10
def validator(function):
    """
    Decorator that indicates that the function being decorated is a validator function.
    """
    function.is_validator = True
    return function