Description
Copying from slack:
On a related note: I think we should have a way to perform JSON-mode validation even when validating from python. Is that currently possible? Otherwise I don't think there's any way to do JSON-style validation of data transported via other protocols, short of doing something like model_validate_json(json.dumps(loaded_cbor_data))
It looks like this isn't currently exposed in pydantic-core, but I'd like to expose it through a keyword argument mode: Literal['python', 'json'] to model_validate which is passed directly through to SchemaValidator.validate_python — the mode is currently just hardcoded as InputType::python there but I don't see any reason we couldn't make it user-specifiable.
In particular, I think this will be handy for doing strict-mode validation of data that didn't have its origin in python (e.g., data loaded from a .yml
file or some other serialization format into python objects).
Selected Assignee: @davidhewitt