Skip to content
You're viewing docs for v2.0. See the latest version →

pydantic.validate_call

Decorators for validating function calls.

ConfigDict

Bases: TypedDict

A dictionary-like class for configuring Pydantic models.

Attributes

title

Type: str | None

str_to_lower

Type: bool

str_to_upper

Type: bool

str_strip_whitespace

Type: bool

str_min_length

Type: int

str_max_length

Type: int | None

extra

Type: ExtraValues | None

frozen

Type: bool

populate_by_name

Type: bool

use_enum_values

Type: bool

validate_assignment

Type: bool

arbitrary_types_allowed

Type: bool

from_attributes

Type: bool

loc_by_alias

Type: bool

alias_generator

Type: Callable[[str], str] | None

ignored_types

Type: tuple[type, ...]

allow_inf_nan

Type: bool

json_schema_extra

Type: dict[str, object] | JsonSchemaExtraCallable | None

strict

Type: bool

revalidate_instances

Type: Literal['always', 'never', 'subclass-instances']

ser_json_timedelta

Type: Literal['iso8601', 'float']

ser_json_bytes

Type: Literal['utf8', 'base64']

validate_default

Type: bool

validate_return

Type: bool

protected_namespaces

Type: tuple[str, ...]

hide_input_in_errors

Type: bool


validate_call

def validate_call(
    config: ConfigDict | None = None,
    validate_return: bool = False,
) -> Callable[[AnyCallableT], AnyCallableT]
def validate_call(__func: AnyCallableT) -> AnyCallableT

Returns a decorated version of the function that validates the arguments and, optionally, the return value.

Returns

AnyCallableT | Callable[[AnyCallableT], AnyCallableT] — The decorated function.

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.


AnyCallableT

Default: TypeVar('AnyCallableT', bound=(Callable[..., Any]))