pub fn validate_insert<S, T>(value: &T) -> Result<(), VldSqlxError>Expand description
Validate a value against schema S before inserting.
use vld::prelude::*;
vld::schema! {
#[derive(Debug)]
pub struct ItemSchema {
pub name: String => vld::string().min(1),
pub qty: i64 => vld::number().int().min(0),
}
}
#[derive(serde::Serialize)]
struct NewItem { name: String, qty: i64 }
let item = NewItem { name: "Widget".into(), qty: 5 };
vld_sqlx::validate_insert::<ItemSchema, _>(&item).unwrap();