vld-salvo
Salvo integration for the vld validation library.
Features
All extractors implement Salvo's Extractible trait and can be used
directly as #[handler] parameters — just like Salvo's built-in
JsonBody or PathParam:
| Extractor | Source | Description |
|---|---|---|
VldJson<T> |
JSON body | Validates JSON request body |
VldQuery<T> |
Query string | Validates URL query parameters |
VldForm<T> |
Form body | Validates URL-encoded form body |
VldPath<T> |
Path params | Validates path parameters |
VldHeaders<T> |
HTTP headers | Validates request headers |
VldCookie<T> |
Cookie header | Validates cookie values |
All extractors implement Deref<Target = T> so you access fields
directly (e.g. body.name instead of body.0.name).
VldSalvoError implements Salvo's Writer trait — validation
failures render as 422 Unprocessable Entity with a JSON error body.
Installation
[]
= "0.1"
= "0.1"
= "0.89"
= "1"
Quick Start
use *;
use *;
schema!
// VldJson<T> is used directly as a handler parameter!
async
async
Path Parameters
Salvo uses {name} syntax for path parameters:
schema!
async
// Router::with_path("users/{id}").get(get_user)
Multiple Extractors
Combine several extractors in a single handler:
async
Error Response Format
Running Examples
Example Requests
# Create user (valid)
# Create user (invalid — triggers 422)
# Get user by id
# Search (query params)
# Health check
License
MIT