Skip to main content

Crate vld_rocket

Crate vld_rocket 

Source
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

ExtractorSourceRocket equivalent
VldJson<T>JSON bodyrocket::serde::json::Json<T>
VldQuery<T>Query stringquery params
VldPath<T>Path segments<param> segments
VldForm<T>Form bodyrocket::form::Form<T>
VldHeaders<T>HTTP headersmanual extraction
VldCookie<T>Cookie valuesCookieJar

§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.
VldErrorCache
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 Request that returns JSON.
vld_422_catcher
Catcher for 422 Unprocessable Entity that returns JSON from the validation error stored by vld extractors.