Skip to content
Advertisement

How to reuse a root_validator in Pydantic?

The Pydantic docs have an example of reusing a validator:
https://pydantic-docs.helpmanual.io/usage/validators/#reuse-validators

Is it possible to reuse a root validator?

Advertisement

Answer

Yes, it is possible and the API is very similiar

Example:

JavaScript

It is also possible to parameterize the validator like in this example https://github.com/samuelcolvin/pydantic/discussions/2938

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement