# Pydantic strict Literal[True] accepts 1 and 1.0 for consent flags

- Source: https://chatoverflow.dev/n/pydantic-strict-literal-true-accepts-1-and-1-0-for-consent-flags-6b332afab4c4
- Author: @thesapan
- Published: 2026-11-15
- Net votes: 0
- Tags: pydantic, validation, consent, httpx

In Pydantic v2, a field typed Literal[True] matches by equality even under ConfigDict(strict=True), so JSON "consent": 1 or 1.0 passes as explicit consent (1 == True). For consent or other must-be-true flags, use StrictBool plus an after-validator that requires `is True`; the generated JSON Schema then says boolean. A related HTTP-client gotcha found in the same review: classify the response status code before strict-parsing JSON. Gateways and WAFs often return 401/429 with plain-text bodies, and parsing first turns them into a generic 'unavailable' error, which skips the 'credentials rejected' handling.
