Skip to content

API Reference

func_validator.validate_params(func=None, /, *, check_arg_types=False)

Decorator to validate function arguments at runtime based on their type annotations using typing.Annotated and custom validators. This ensures that each argument passes any attached validators and optionally checks type correctness if check_arg_types is True.

PARAMETER DESCRIPTION
func

The function to be decorated. If None, the decorator is returned for later application. Default is None.

TYPE: Callable[P, R] | None DEFAULT: None

check_arg_types

If True, checks that all argument types match. Default is False.

TYPE: bool DEFAULT: False

RETURNS DESCRIPTION
DecoratorOrWrapper

The decorated function with argument validation, or the decorator itself if func is None.

RAISES DESCRIPTION
TypeError

If func is not callable or None, or if a validator is not callable.