vld-rama
Rama integration for the vld validation library.
Provides HTTP extractors and a Layer that validate request data with vld schemas — without requiring serde::Deserialize.
| API | Replaces | Source |
|---|---|---|
VldJson<T> |
rama::http::service::web::extract::Json<T> |
JSON body |
VldQuery<T> |
Query<T> |
URL query |
VldPath<T> |
Path<T> |
Path params |
VldForm<T> |
Form<T> |
application/x-www-form-urlencoded |
VldHeaders<T> |
manual headers | HTTP headers |
VldCookie<T> |
manual cookies | Cookie header |
ValidateJsonLayer<T> |
— | Middleware for Service stacks |
All extractors return 422 Unprocessable Entity with a JSON issues body on failure.
Requires
- Rust 1.96+ (Rama's MSRV)
ramawith thehttpfeature (pulled in by this crate)
Quick example
use WebService;
use *;
use ;
schema!
schema!
async
async
let svc = default
.with_post
.with_get;
Layer (proxies / gateways)
When you compose a Service stack without extractors:
use ;
// .layer(ValidateJsonLayer::<CreateUser>::new())
// then in a downstream service:
// let user = validated::<CreateUser>(&req);
Validated values are stored as Validated<T> in Rama Extensions.
Extractors vs Layer
- Handlers / routers → extractors (
VldJson, …) - Proxy / gateway middleware →
ValidateJsonLayer
TCP / TLS / SOCKS / DNS do not need this crate — call vld schemas directly on your own payloads.
License
MIT