Getting started

Installation

Add vld to Cargo.toml and pick the features you need.

Add the crate

Cargo.toml
[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.

FeatureEnablesExtra dependencies
derive#[derive(Validate)] (guide)vld-derive
openapiJsonSchema trait, json_schema(), to_openapi_document() (guide)none
diffvld::diff::diff_schemas for breaking-change detection; implies openapi (guide)none
llmvld::llm: JSON Schemas for OpenAI / Anthropic / Gemini, parse_llm, VldError::llm_feedback(); implies openapi (guide)none
regexvld::string().pattern(...), regex_syntax(), vld::rules::Patternregex-lite
chronovld::chrono::{date, datetime, time} (guide)chrono
jiffvld::jiff::{date, datetime, time}; string().timezone() checks names against jiff's time zone databasejiff
timevld::time::{date, datetime, time}time
decimalvld::decimal() (rust_decimal::Decimal), vld::money() (guide)rust_decimal
geovld::latitude(), longitude(), geo_point(), geojson() (guide)none
netvld::ip_network() (ipnet::IpNet)ipnet
filevld::file() with size, extension and media-type checksinfer
file-advancedfile plus sha256() / md5(), image dimensions, require_exif()sha2, md-5, image, kamadak-exif
string-advancedurl_strict(), uri(), uuid_v1/v4/v7(), phone_e164_strict(), semver_full(), typed vld::uuid() / vld::url()url, uuid, phonenumber, semver
unicodestring().normalize_nfc() / normalize_nfkc(), single_script() (guide)unicode-normalization, unicode-security
password-strengthstring().password_strength(score) (zxcvbn estimate) (guide)zxcvbn
i18nvld::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-allone more embedded language (i18n-fr, i18n-ja, …: 25 more), or all 29—
cryptovld::crypto, string().crypto_address(...): wallet addresses with checksums (guide)sha2, sha3, blake2
tsvld::ts: Zod / Valibot / TypeScript codegen; implies openapi (guide)none
fakevld::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.

CrateModules
vld-webweb 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-openapiutoipa5 / utoipa6, schemars0 / schemars1 (also aide), poem_openapi, validator
vld-datasqlx08 / sqlx09, diesel, sea1 / sea2, surrealdb, redis0 / redis1, lapin2 / lapin3 / lapin4, bson2 / bson3, postgres_types, clickhouse, rumqttc, nats, centrifuge, socketio, csv
vld-appconfig, env, clap, tauri
Cargo.toml
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.