Expand description
§vld-rocket — Rocket integration for vld
Validation extractors for Rocket. Validates request
data against vld schemas and returns 422 Unprocessable Entity with
structured JSON errors on failure.
§Extractors
| Extractor | Source | Rocket equivalent |
|---|---|---|
VldJson<T> | JSON body | rocket::serde::json::Json<T> |
VldQuery<T> | Query string | query params |
VldPath<T> | Path segments | <param> segments |
VldForm<T> | Form body | rocket::form::Form<T> |
VldHeaders<T> | HTTP headers | manual extraction |
VldCookie<T> | Cookie values | CookieJar |
§Error catcher
Register [vld_catcher()] to get JSON error responses instead of the
default HTML:
ⓘ
rocket::build()
.mount("/", routes![...])
.register("/", catchers![vld_rocket::vld_422_catcher])Modules§
- prelude
- Prelude — import everything you need.
Structs§
- VldCookie
- Validated cookie extractor for Rocket.
- VldError
Cache - Stored in request local cache so the catcher can read it.
- VldForm
- Validated form body extractor.
- VldHeaders
- Validated HTTP headers extractor for Rocket.
- VldJson
- Validated JSON body extractor.
- VldPath
- Validated path parameter extractor for Rocket.
- VldQuery
- Validated query string extractor.
Functions§
- vld_
400_ catcher - Catcher for
400 Bad Requestthat returns JSON. - vld_
422_ catcher - Catcher for
422 Unprocessable Entitythat returns JSON from the validation error stored by vld extractors.