Validate Call
Decorator for validating function calls.
validate_call
Section titled “validate_call”def validate_call(
*,
config: ConfigDict | None = None,
validate_return: bool = False,
) -> Callable[[AnyCallableT], AnyCallableT]
def validate_call(func: AnyCallableT, /) -> AnyCallableTReturns a decorated wrapper around the function that validates the arguments and, optionally, the return value.
Usage may be either as a plain decorator @validate_call or with arguments @validate_call(...).
When a decorated call fails, the ValidationError names the rejected argument, but the traceback won’t show the value the caller passed. Logfire records failing calls along with their arguments — see Troubleshooting validation errors.
Returns
Section titled “Returns”AnyCallableT | Callable[[AnyCallableT], AnyCallableT] — The decorated function.
Parameters
Section titled “Parameters”func : AnyCallableT | None Default: None
The function to be decorated.
config : ConfigDict | None Default: None
The configuration dictionary.
validate_return : bool Default: False
Whether to validate the return value.
Was this page helpful?