-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Feature Request
Please complete:
- OS: Linux, Ubuntu
- Python version
import sys; print(sys.version): 3.7 - Pydantic version
import pydantic; print(pydantic.VERSION): 1.1.1
If field validation fails there often is no need to call root validator as it will fail too because fields are not available.
I suggest that new parameter is added to root_validator decorator that disables call of root_validator if field validation failed.
@root_validator(pre=False, call_on_field_failure=False)
See relevant quote from documentation about current behavior:
Field validation will not occur if pre=True root validators raise an error. As with field validators, "post" (i.e. pre=False) root validators will be called even if field validation fails; the values argument will be a dict containing the values which passed field validation and field defaults where applicable.
From https://pydantic-docs.helpmanual.io/usage/validators/
Thank you all for developing this library!