Installation
Add the crate
[dependencies]
vld = "0.8"
Or with cargo:
cargo add vld
cargo add vld --features derive,openapi
The minimum supported Rust version of vld is 1.90 with every feature. Some integration features need more; see MSRV.
Features
No feature is enabled by default. Everything below is additive.
| Feature | Enables | Extra dependencies |
|---|---|---|
derive | #[derive(Validate)] (guide) | vld-derive |
openapi | JsonSchema trait, json_schema(), to_openapi_document() (guide) | none |
diff | vld::diff::diff_schemas for breaking-change detection; implies openapi (guide) | none |
llm | vld::llm: JSON Schemas for OpenAI / Anthropic / Gemini, parse_llm, VldError::llm_feedback(); implies openapi (guide) | none |
regex | vld::string().pattern(...), regex_syntax(), vld::rules::Pattern | regex-lite |
chrono | vld::chrono::{date, datetime, time} (guide) | chrono |
jiff | vld::jiff::{date, datetime, time}; string().timezone() checks names against jiff's time zone database | jiff |
time | vld::time::{date, datetime, time} | time |
decimal | vld::decimal() (rust_decimal::Decimal), vld::money() (guide) | rust_decimal |
geo | vld::latitude(), longitude(), geo_point(), geojson() (guide) | none |
net | vld::ip_network() (ipnet::IpNet) | ipnet |
file | vld::file() with size, extension and media-type checks | infer |
file-advanced | file plus sha256() / md5(), image dimensions, require_exif() | sha2, md-5, image, kamadak-exif |
string-advanced | url_strict(), uri(), uuid_v1/v4/v7(), phone_e164_strict(), semver_full(), typed vld::uuid() / vld::url() | url, uuid, phonenumber, semver |
unicode | string().normalize_nfc() / normalize_nfkc(), single_script() (guide) | unicode-normalization, unicode-security |
password-strength | string().password_strength(score) (zxcvbn estimate) (guide) | zxcvbn |
i18n | vld::i18n::translator(locale), Translator::new(view), files(): messages from the embedded JSON catalogs (en, ru, de, es), CLDR plurals (guide) | i18n-next (no default features) |
i18n-<lang>, i18n-all | one more embedded language (i18n-fr, i18n-ja, …: 25 more), or all 29 | — |
crypto | vld::crypto, string().crypto_address(...): wallet addresses with checksums (guide) | sha2, sha3, blake2 |
ts | vld::ts: Zod / Valibot / TypeScript codegen; implies openapi (guide) | none |
fake | vld::fake: test data that passes a schema; implies openapi (guide) | rand, regex-lite, regex-syntax |
The date features can be enabled together. vld::date(), vld::datetime() and vld::time_of_day() exist only when exactly one of them is on; with several, call the backend module (vld::chrono::date()). See Dates.
Integration crates
Integrations live in four group crates, one module per library, each behind its feature (none is on by default). Any set of features can be enabled together, including several majors of one library.
| Crate | Modules |
|---|---|
vld-web | web frameworks: axum, actix, ntex3 / ntex4, poem, rocket, salvo, warp, rama, tower, tonic, async_graphql, tungstenite, axum::ws (axum-ws), lambda, common; AI tools: rmcp, rig |
vld-openapi | utoipa5 / utoipa6, schemars0 / schemars1 (also aide), poem_openapi, validator |
vld-data | sqlx08 / sqlx09, diesel, sea1 / sea2, surrealdb, redis0 / redis1, lapin2 / lapin3 / lapin4, bson2 / bson3, postgres_types, clickhouse, rumqttc, nats, centrifuge, socketio, csv |
vld-app | config, env, clap, tauri |
vld-web = { version = "0.8", features = ["axum"] }
Coming from 0.7's per-integration crates (vld-axum, vld-sqlx, …): see the migration guide.
Prelude
Most code needs a single import:
use vld::prelude::*;
It brings in the VldSchema, VldParse and VldInput traits, the error types (VldError, ValidationIssue, IssueCode, PathSegment), the formatting helpers and every schema type. With openapi it also exports the JsonSchema trait.
The schema constructors are free functions: vld::string(), vld::number(), vld::array(...). They are not in the prelude, so call them with the vld:: prefix.
WebAssembly
The core has no platform-specific code; vld (including vld::form, used by Leptos / Dioxus apps) builds for wasm32-unknown-unknown (checked by just wasm). Checks that touch the filesystem (path().exists(), file()) are not meaningful in a browser.