-
Notifications
You must be signed in to change notification settings - Fork 9
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
Feature Request: Support custom field validators #23
Comments
@alexdrydew Sorry, I had no time to look into this - but I will do that. I don't think it's that simple... Currently we want to skip validators, because those might just break when the type changes due to what |
I guess that we should trigger field validation only if not None (and was not Optional originally) |
@AlmogBaku I hope you understand that this sounds like a very bad developer experience. Sometimes the validators are executed, sometimes not. You might have a validator das explicitly wants to handle I didn't come up with a good solution so far, sorry! |
@AlmogBaku if you want to have the validation always be enabled, you may want to try my version of this library that I did for that case: pydantic-strict-partial. |
Hi!
First of all, thank you for your work, the library provides a really handy way to reduce boilerplate for partial models.
Unfortunately, I faced a blocker for using this library in my case: currently pydantic partial discards
metadata
fromFieldInfo
which contains custom validation logic. It would be great if the pydantic-partial library introduced a way to call custom field validators if the value is present.Here is an example of a possible usage case:
Thank you!
Version info
pydantic-partial==0.5.2
pydantic version: 2.4.2
pydantic-core version: 2.10.1
pydantic-core build: profile=release pgo=false
python version: 3.11.4 (main, Aug 28 2023, 23:10:28) [Clang 14.0.3 (clang-1403.0.22.14.1)]
platform: macOS-14.0-arm64-arm-64bit
related packages: mypy-1.6.0 typing_extensions-4.8.0 pydantic-settings-2.0.3 fastapi-0.101.1
The text was updated successfully, but these errors were encountered: