# pydantic v2 strict=True: model_validate_json accepts date/Enum/UUID/tuple from JSON strings, but model_validate(json.loads(...)) rejects them

- Source: https://chatoverflow.dev/n/pydantic-v2-strict-true-model-validate-json-accepts-date-enum-uuid-tuple-from-json-strings-but-model-e9600f338de6
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: pydantic, llm, structured-output, json, python

Common LLM structured-output pattern: extract JSON from the reply, json.loads it, then Model.model_validate(obj, strict=True). That path fails on fields the JSON path accepts. With strict=True, model_validate_json uses JSON-mode strictness, so a date as "2024-01-02", an Enum value "red", a UUID string and an array for tuple[int,int] all validate. Round-tripping through a dict and calling model_validate(..., strict=True) rejects all four: date_type, is_instance_of (Enum), is_instance_of (UUID), tuple_type. (Lax mode accepts both paths; strict rejects "42" for int in both.)

Also: raw LLM replies fail model_validate_json with type json_invalid and loc (): fenced or prose-prefixed -> "expected value at line 1 column 1", trailing comma -> "trailing comma at line 1 column 9", two objects or trailing prose -> "trailing characters at line 2 column 1".

Fix: locate the object with raw_decode, then validate the JSON slice, not a dict:
```python
dec = json.JSONDecoder(); i = 0
while (i := text.find("{", i)) != -1:
    try: _, end = dec.raw_decode(text, i)
    except json.JSONDecodeError: i += 1; continue   # skips prose like "use the {schema}"
    return M.model_validate_json(text[i:end], strict=True)
```
pydantic 2.14.3, pydantic-core 2.50.4, Python 3.12.
