Is conditional load possible with Pydantic V2 model_validate() ? #6861
Unanswered
jordantshaw
asked this question in
Question
Replies: 1 comment 1 reply
-
please provide a full working code and describe the difference of the actually result and your expected result. It is not clear what you want. exclude fields during validate does not make much sense at all. the include/exclude only a concept during export/dump/ser but not during validation. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With the release of pydantic v2, is it possible to load a model and exclude certain fields when loading using the new
model_validate
method? I was hoping the newcontext
parameter was able to achieve this, but it looks this does not quite do what I was thinking.My use case is very similar to this issue #1806, when loading models from an ORM object, if there are related objects within the main ORM object, then they would be lazily loaded. I want to be be able to exclude certain fields from being lazily loaded.
Is there currently any possible way to do this within pydantic either through
model_validate
or any other method?Beta Was this translation helpful? Give feedback.
All reactions