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
on_error
validator and field property
#151
Comments
Hi @samuelcolvin What would be the expected API for this?
But I guess we could have everything behind a function and avoid this distinction. And I may also miss some usecases |
I could just have just a bool
|
The thing is I've seen some usecases (and pydantic issues) where you would want to log bad values, or put them in some kind of global array or whatever. So calling a function with the bad value could be something useful. And it would allow people to put a different default value for omitted inputs vs wrong inputs |
Yes, but can't we just use existing wrap validators for that? |
I see what you mean ok! I'll work on it soon |
maybe we should make it a literal of options as you suggested so it's easier to extend in future? |
I'll go with a literal for
Because there are some usecases where we want to differentiate missing input value (e.g. @samuelcolvin are you ok with this? If yes I'll reopen my old PR and change implementation EDIT: Names can be changed of course but I reckon it's a good idea to allow omitting values on errors even if a default is set |
TypeDict
Field
which allows the value to be omitted or the default to be used if an error occursThe text was updated successfully, but these errors were encountered: