Allow access to field_name and data in all validators if there is data and a field name - #7542
Merged
Merged
Conversation
Deploying with
|
| Latest commit: |
ade9bc0
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://1d8a4f52.pydantic-docs2.pages.dev |
| Branch Preview URL: | https://valdationinfo.pydantic-docs2.pages.dev |
13 tasks
samuelcolvin
force-pushed
the
ValdationInfo
branch
from
September 21, 2023 18:21
0677d08 to
8ad7752
Compare
samuelcolvin
marked this pull request as ready for review
September 21, 2023 20:25
Member
Author
|
please review. |
adriangb
reviewed
Sep 21, 2023
| !!!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__` |
Member
There was a problem hiding this comment.
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?
Member
Author
There was a problem hiding this comment.
no, but it's the only way to make what we're doing possible.
adriangb
approved these changes
Sep 21, 2023
samuelcolvin
enabled auto-merge (squash)
September 22, 2023 10:21
13 tasks
1 task
xsedla1o
added a commit
to CESNET/dp3
that referenced
this pull request
Jun 4, 2026
Has been deprecated [for a while now](pydantic/pydantic#7542), was somehow overlooked in previous iterations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_schemahave been changed.Fix #7448
fix #6794
Fix #6345
TODO:
Selected Reviewer: @adriangb