Skip to main content

model_validator

No overview available.

def model_validator(
mode: Literal['after']
) - > Callable

Decorates a model method to perform validation either before or after the standard model validation process.

Parameters

NameTypeDescription
modeLiteral['after']Specifies the validation timing; 'after' indicates the validator runs after the model has been initialized and field-level validation is complete.

Returns

TypeDescription
CallableA decorator that wraps the validation function and attaches Pydantic-specific metadata for model processing.