-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Update validator docs #6695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update validator docs #6695
Conversation
Deploying with
|
| Latest commit: |
389c464
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://a62599f5.pydantic-docs2.pages.dev |
| Branch Preview URL: | https://validators.pydantic-docs2.pages.dev |
|
please review |
|
|
||
| ## Special Types | ||
| ## Field validators |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like it might make more sense to start with this section than the annotated validators, since 1, this is closer to existing usage, and 2, it doesn't introduce the concept of using Annotated. I feel like it introduces just the concept of a validator function, which then motivates the idea of using Annotated validators as a way to make them reusable by way of a reused type annotation (rather than needing to set up the validator on every model you want to use it with).
I'm fine if you disagree, I just think this topic is quicker to understand and lowers the barrier to understand the annotated ones.
docs/usage/validators.md
Outdated
| As with field validators, root validators can have `pre=True`, in which case they're called before field | ||
| validation occurs (and are provided with the raw input data), or `pre=False` (the default), in which case | ||
| they're called after field validation. | ||
| Model validators can be `mode='before'` or `mode='after'` and `mode='wrap'`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Model validators can be `mode='before'` or `mode='after'` and `mode='wrap'`. | |
| Model validators can be `mode='before'`, `mode='after'`, or `mode='wrap'`. |
It seems a little weird to have both "and" and "or" in the same list here, unless there is something weird going on where mode='after' and mode='wrap' deserve to be considered as a group, separate from mode='before'. (I don't think that's the case, but I just want to make sure I'm not missing some implied nuance here.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, though I have made various suggestions you can take or leave.
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Co-authored-by: David Montague <35119617+dmontagu@users.noreply.github.com>
Goals:
Selected Reviewer: @dmontagu