Skip to main content

ValidateAs

A helper class to validate a custom type from a type that is natively supported by Pydantic.

Attributes

AttributeTypeDescription
from_typetype[_FromTypeT]The type natively supported by Pydantic to use to perform validation.
instantiation_hookCallable[[_FromTypeT], Any]A callable taking the validated type as an argument, and returning the populated custom type.

Constructor

Signature

def ValidateAs(
from_type: type[_FromTypeT],
instantiation_hook: Callable[[_FromTypeT], Any]
) - > None

Parameters

NameTypeDescription
from_typetype[_FromTypeT]The type natively supported by Pydantic to use to perform validation.
instantiation_hookCallable[[_FromTypeT], Any]A callable taking the validated type as an argument, and returning the populated custom type.

Signature

def ValidateAs(
from_type: type[_FromTypeT],
instantiation_hook: Callable[[_FromTypeT], Any]
)

Parameters

NameTypeDescription
from_typetype[_FromTypeT]The Pydantic-compatible type used as the intermediate schema for initial validation.
instantiation_hookCallable[[_FromTypeT], Any]A callback function that receives the validated intermediate object and returns the final custom class instance.