Expand description
§vld-sqlx — SQLx integration for the vld validation library
Validate data before inserting into the database, and use strongly-typed validated column types with SQLx.
§Quick Start
ⓘ
use vld_sqlx::prelude::*;
vld::schema! {
#[derive(Debug)]
pub struct NewUserSchema {
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 user = NewUser { name: "Alice".into(), email: "alice@example.com".into() };
validate_insert::<NewUserSchema, _>(&user)?;
// now safe to insert via sqlx::query!(...)Re-exports§
pub use vld;
Modules§
Structs§
- Validated
- A wrapper that proves its inner value has been validated against schema
S. - VldBool
- A validated boolean column type.
- VldFloat
- A validated float column type.
- VldInt
- A validated integer column type.
- VldText
- A validated text column type.
Enums§
- VldSqlx
Error - Error returned by
vld-sqlxoperations.
Functions§
- validate_
insert - Validate a value against schema
Sbefore inserting. - validate_
row - Validate a row loaded from the database against schema
S. - validate_
rows - Validate a batch of rows against schema
S. - validate_
update - Alias for
validate_insert— same logic applies to updates.