RuleCheckAllKw Class
- class kwhelp.decorator.RuleCheckAllKw(arg_info: Dict[str, Union[int, kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]], rules: Optional[Iterable[Union[kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]]] = None, **kwargs)[source]
Decorator that decorates methods that require specific args to match rules specificed in
ruleslist.If a function specific args do not match all matching rules in
ruleslist then validation will fail.See also
- __init__(arg_info: Dict[str, Union[int, kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]], rules: Optional[Iterable[Union[kwhelp.rules.IRule, Iterable[kwhelp.rules.IRule]]]] = None, **kwargs)[source]
Constructor
- Parameters
arg_info (Dict[str, Union[int, IRule, Iterable[IRule]]]) – Dictionary of Key and int, IRule, or Iterable[IRule]. Each Key represents that name of an arg to check with one or more rules. If value is int then value is an index that corresponds to an item in
rules.rules (Iterable[Union[IRule, Iterable[IRule]]], optional) – List of rules for arg_info entries to match. Default
None
- Keyword Arguments
raise_error (bool, optional) –
If
Truethen an Exception will be raised if a validation fails. The kind of exception raised depends on the rule that is invalid. Typically aTypeErroror aValueErroris raised.If
Falsethen an attribute will be set on decorated function namedis_rules_kw_all_validindicating if validation status. DefaultTrue.ftype (DecFuncType, optional) – Type of function that decorator is applied on. Default
DecFuncType.FUNCTIONopt_return (object, optional) – Return value when decorator is invalid. By default an error is rasied when validation fails. If
opt_returnis supplied then it will be return when validation fails and no error will be raised.opt_logger (Union[Logger, LoggerAdapter], optional) – Logger that logs exceptions when validation fails.