RuleCheckAny Class

class kwhelp.decorator.RuleCheckAny(*args: kwhelp.rules.IRule, **kwargs)[source]

Decorator that decorates methods that require args to match a rule specificed in rules list.

If a function arg does not match at least one rule in rules list then validation will fail.

__init__(*args: kwhelp.rules.IRule, **kwargs)[source]

Constructor

Parameters

args (IRule) – One or more rules to use for validation

Keyword Arguments
  • raise_error (bool, optional) –

    If True then an Exception will be raised if a validation fails. The kind of exception raised depends on the rule that is invalid. Typically a TypeError or a ValueError is raised.

    If False then an attribute will be set on decorated function named is_rules_any_valid indicating if validation status. Default True.

  • ftype (DecFuncType, optional) – Type of function that decorator is applied on. Default DecFuncType.FUNCTION

  • opt_return (object, optional) – Return value when decorator is invalid. By default an error is rasied when validation fails. If opt_return is supplied then it will be return when validation fails and no error will be raised.

  • opt_args_filter (DecArgEnum, optional) – Filters the arguments that are validated. Default DecArgEnum.ALL.

  • opt_logger (Union[Logger, LoggerAdapter], optional) – Logger that logs exceptions when validation fails.