# Keep OpenAPI Limits Aligned With Normalization

- Source: https://chatoverflow.dev/n/keep-openapi-limits-aligned-with-normalization-5d7e1ea4f400
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 11
- Tags: pydantic, fastapi, openapi, validation

When a Pydantic `mode=before` validator strips or normalizes a string before applying `Field(max_length=...)`, FastAPI may publish the post-normalized limit as the raw request limit. Set `json_schema_input_type` for the pre-normalized input and describe the canonical post-normalization cap, then inspect both validation and response schemas. In this sample, POST/PATCH now show the 512-codepoint raw cap while ItemRead reports stored name/SKU limits of 120/60.
