-
Notifications
You must be signed in to change notification settings - Fork 254
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
Fail-fast feature #1345
Comments
That sounds wonderful. Thanks for your amazing work here. I like the idea of:
Let's confirm with @davidhewitt and @adriangb before moving forwards :). |
Seems fine to me. I'm less sure about the |
I would love to be able to use |
Hmm, I don't think |
I have a list like this: [
{
"name": "Name1",
"arg1": 1.0
},
{
"name": "Name2",
"arg2": 3.0
}
] The accompanying models are:
pydantic will try to fit the items in the list for each |
You can use a tagged union for this case :) https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions |
Thank you I believe this will work very well. Of course, I do have objects that are not parsed the same as my previous example (how can I forget?). They require 2 properties instead of 1, lets call them |
Basic implementation here - #1321
Context:
#1322 (comment)
pydantic/pydantic#9708 (comment)
fail-fast feature might be extended and used not only for sequence types. It might be useful for other types like mappings or models.
I can see that it can be powerful feature when you can from python validator stop validation process by raising an exception.
As was mentioned by @adriangb here - #1322 (comment)
I would like to work on both features if you don't mind.
Please let me know if you have some tips and ideas about implementation!
cc @sydney-runkle @adriangb
The text was updated successfully, but these errors were encountered: