ValidateAs
A helper class to validate a custom type from a type that is natively supported by Pydantic.
Attributes
| Attribute | Type | Description |
|---|---|---|
| from_type | type[_FromTypeT] | The type natively supported by Pydantic to use to perform validation. |
| instantiation_hook | Callable[[_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
| Name | Type | Description |
|---|---|---|
| from_type | type[_FromTypeT] | The type natively supported by Pydantic to use to perform validation. |
| instantiation_hook | Callable[[_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
| Name | Type | Description |
|---|---|---|
| from_type | type[_FromTypeT] | The Pydantic-compatible type used as the intermediate schema for initial validation. |
| instantiation_hook | Callable[[_FromTypeT], Any] | A callback function that receives the validated intermediate object and returns the final custom class instance. |