vld-data 0.9.0

Database and message-queue integrations for the vld validation library: sqlx, diesel, SeaORM, SurrealDB, MongoDB (bson), tokio-postgres, ClickHouse, redis, lapin, MQTT, NATS, Centrifugo, Socket.IO, CSV import
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

vld::schema! {
    #[derive(Debug)]
    pub struct UserInput {
        pub name: String  => vld::string().min(1).max(100),
        pub email: String => vld::string().email(),
    }
}

#[derive(serde::Serialize)]
struct NewUser { name: String, email: String }

let dto = NewUser { name: "Alice".into(), email: "alice@example.com".into() };
let parsed = validate_model::<UserInput, _>(&dto).unwrap();
assert_eq!(parsed.name, "Alice");