ArgsLen Class
- class kwhelp.decorator.ArgsLen(*args: Union[type, Iterable[type]], **kwargs)[source]
Decorartor that sets the number of args that can be added to a function
- Raises
ValueError – If wrong args are passed into construcor.
ValueError – If validation of arg count fails.
See also
- __init__(*args: Union[type, Iterable[type]], **kwargs)[source]
Constructor
- Parameters
args (Union[int, iterable[int]]) –
One or more int or Iterator[int] for validation.
Single
int
values are to match exact.iterable[int]
must be a pair ofint
with the firstint
less then the secondint
.
- Keyword Arguments
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_logger (Union[Logger, LoggerAdapter], optional) – Logger that logs exceptions when validation fails.