Runtime validation for Rust, the Zod way
vld describes the shape of your data once and checks untrusted input against it: JSON bodies, query strings, config files, database rows. Errors list every problem with its path, and the same schema produces OpenAPI.
What you get
Two minutes to the first parse
Add the crate, describe a struct and call parse(). Invalid input returns a VldError with every issue, not just the first.
Type-safe runtime validation for Rust, inspired by Zod: describe the data once, get typed values, every error with its path, and JSON Schema / OpenAPI.
cargo add vld --features derive,openapi
main.rs
use vld::prelude::*;
vld::schema! {
#[derive(Debug)]
pub struct User {
pub name: String => vld::string().min(2).max(50),
pub email: String => vld::string().email(),
pub age: Option<u8> => vld::u8().min(18).optional(),
}
}
let user = User::parse(r#"{"name": "Alex", "email": "alex@example.com"}"#)?;
assert_eq!(user.age, None);
Start with the introduction or the quick start.