Provide a mode
parameter in validate_python
and model_validate
#9009
Labels
mode
parameter in validate_python
and model_validate
#9009
Initial Checks
Description
Given the following:
The following two calls will differ in behavior:
This is because
validate_python
really expects an instance of aBlah
instead of adict
, whereasvalidate_json
loosens the rules here.This is a problem if the data has already been parsed from JSON, or comes from a source other than JSON (e.g. YAML).
A suggestion for exposing something like this already exists over at pydantic-core (pydantic/pydantic-core#712).
This issue is really more meant to track exposing the same logic in the appropriate methods Pydantic ships.
Affected Components
.model_dump()
and.model_dump_json()
model_construct()
, pickling, private attributes, ORM modeThe text was updated successfully, but these errors were encountered: