Specifying types for extra fields #9442
Unanswered
mdekstrand
asked this question in
Question
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have a data modeling problem where we have a model that has one known field of type
A
, and unknown fields all of typeB
. Effectively, it is adict[str,B]
, except one name'foo'
has typeA
. We'd like to be able to parse this into something like this:Not wedded to that specific class design, but it's the basic idea. I know approximately how I would write this in Zod:
What is a good way to represent and validate such a model in Pydantic?
Beta Was this translation helpful? Give feedback.
All reactions