Repository navigation
Add python validators for decimal constraints (max_digits and decimal_places) - #10506
Conversation
Deploying pydantic-docs with
|
| Latest commit: |
9adef0c
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://99e28bdc.pydantic-docs.pages.dev |
| Branch Preview URL: | https://add-decimal-validators.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #10506 will not alter performanceComparing Summary
|
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||
Co-authored-by: Alex Hall <alex.mojaki@gmail.com>
|
I think it's alright if I merge this (given the approval and iterations on feedback), but if there's anything left unaddressed, happy to open another PR on Monday! |
|
I'm wondering: why is the Python validation only called when a validator is already present? Can we avoid duplication between pydantic-core and here? Other thing, seems like |
Good question. I think this issue helps to explain things: #10036 Specifically, we use these Python validators for cases where it'd violate our promise to maintain the order of annotations if we directly applied the constraint to the core schema. But, the validator is still compatible with the type after the custom validator is called, so we can use these python wrappers. |
Closes #10498
This specifically addresses issues where there is annotated metadata applied between the type and the decimal constraints.
For this sample:
The output used to be: