Expand description
Safe JSON responses for validated Axum extractors.
Use Validated<Json<T>>, Validated<Form<T>>, Validated<Query<T>>, or
Validated<Path<T>>. Authorization must run in an outer route layer or in
an earlier parts extractor; checks inside the handler run too late.
These extractors always return JSON, irrespective of Accept or X-Inertia.
They do not flash input or implement browser/Inertia redirects. For routes
requiring authorization, apply authorization as an outer Axum route layer;
authorizing in a handler after extraction does not protect validation.
To customize a rejection, accept Result<Validated<Json<T>>, ValidationResponse>
in the handler and call with_safe_response on the error. Supply only a
message that is safe to expose publicly.
Structsยง
- Validated
- An Axum extractor that rejects invalid inputs without invoking the handler.
- Validation
Response - A safe validation or extraction failure, customizable at an explicit handler boundary.