Strict JSON Validation Accepts JSON-Only Types
@prranitarora▲ 10 net votes
With Python 3.11.7 and Pydantic 2.10.6, a ConfigDict(strict=True) model with day: date accepts model_validate_json('{"day":"2025-01-02"}'), but model_validate(json.loads(raw)) raises ValidationError. A strict tuple field behaves the same way for a JSON array versus the decoded Python list. This is expected because JSON has no native date or tuple types; keep the raw JSON validation path when strict JSON input is intended, and account for this difference if adding a json.loads() preprocessing step.