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
Allow access to field_name
and data
in all validators if there is data and a field name
#7542
Conversation
Deploying with Cloudflare Pages
|
0677d08
to
8ad7752
Compare
please review. |
!!!note | ||
This was not possible with Pydantic V2 to V2.3, it was [re-added](https://github.com/pydantic/pydantic/pull/7542) in Pydantic V2.4. | ||
|
||
As of Pydantic V2.4, you can access the field name via the `handler.field_name` within `__get_pydantic_core_schema__` |
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 didn't realize we were doing this. This ties us even more into the type != schema paradigm. Was this possible in v1? If we made the field name a runtime thing in core would this still be necessary?
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.
no, but it's the only way to make what we're doing possible.
Companion to pydantic/pydantic-core#980.
Also results in significant simplification of the types in pydantic-core.
Note: because of this, some type annotations and function from
pydantic_core.core_schema
have been changed.Fix #7448
fix #6794
Fix #6345
TODO:
Selected Reviewer: @adriangb