Pydantic strict validation can accept a JSON date string that Python validation rejects

If an AI tool result contains a date, moving JSON decoding one step earlier can change whether Pydantic accepts it—even with strict=True on both validation calls.

The small example in Pydantic’s Strict Mode documentation makes the distinction concrete:

from datetime import date
from pydantic import TypeAdapter, ValidationError

adapter = TypeAdapter(date)

# JSON input: the document contains a quoted date string.
value = adapter.validate_json('"2000-01-01"', strict=True)
# Documented result: date(2000, 1, 1)

# Python input: a str, not a date instance.
try:
    adapter.validate_python('2000-01-01', strict=True)
except ValidationError:
    print("Python string rejected in strict mode")

This is adapted from the documentation, not a locally executed test. It uses Pydantic’s TypeAdapter API; check it against your installed version before treating it as a regression fixture.

The boundary is part of the contract

Strict mode does not mean “all input paths accept exactly the same representations.” The documentation explicitly allows looser rules for JSON input for types such as dates and times. In its date example, strict JSON validation accepts the date string, strict Python validation rejects the string, and lax Python validation accepts it.

That matters when a tool-result handler changes from passing raw JSON to Pydantic to decoding it first. For the scalar JSON document "2000-01-01", ordinary json.loads produces the Python string '2000-01-01'. Passing that string to validate_python(..., strict=True) takes the rejecting path above. This is an integration consequence of the documented example, not evidence that an AI model generated a worse answer.

The accommodation is type-specific. It does not mean strict mode allows arbitrary string coercion: the same page shows strict Python model validation rejecting '123' for an integer field. Don’t extrapolate the date rule to every field in a tool schema.

Before refactoring a tool-result handler

My recommendation is to make the accepted input representation explicit:

  • If the contract is raw JSON, keep validation at that boundary and test the JSON date-string case.
  • If the contract is Python objects, define whether the caller must supply typed dates or whether an explicit conversion step belongs upstream. Don’t assume a decoded string is a typed date.
  • When changing the boundary, add paired tests for the same date value through JSON and Python validation. Assert acceptance or rejection deliberately, then extend the tests to the actual tool-result schema and any custom validators.

Turning strict mode off everywhere may hide the distinction rather than resolve it. Choose the boundary first; then choose the coercions you intend to allow.

Scope note: this is about application-side Pydantic validation, not a claim about provider-side structured-output guarantees. The source is the moving latest documentation captured on September 10, 2026; it does not establish behavior for every installed release.