Migration
From 0.7 to 0.8
Crates merged into six
The 30 crates became six. Every integration is a module of a group crate, behind a feature; no feature is on by default, so name what you use. Several majors of one library (ntex 3 / 4, utoipa 5 / 6, sqlx 0.8 / 0.9, …) are separate features and modules that can be enabled together. Items inside each module keep their 0.7 names.
| 0.7 crate | 0.8 crate, feature | Path |
|---|---|---|
vld-axum, vld-actix, vld-poem, vld-rocket, vld-salvo, vld-warp, vld-rama, vld-tower, vld-tonic | vld-web, <name> | vld_web::<name> |
vld-ntex | vld-web, ntex-3 / ntex-4 (+ ntex-compress) | vld_web::ntex3 / ntex4 |
vld-http-common | vld-web | vld_web::common |
vld-utoipa | vld-openapi, utoipa-5 / utoipa-6 | vld_openapi::utoipa5 / utoipa6 |
vld-schemars, vld-aide | vld-openapi, schemars-0 / schemars-1 | vld_openapi::schemars0 / schemars1, vld_openapi::validator |
vld-ts, vld-fake | vld, ts / fake | vld::ts, vld::fake |
vld-leptos, vld-dioxus | vld | vld::form |
vld-sqlx | vld-data, sqlx-0_8 / sqlx-0_9 + sqlite / postgres / mysql | vld_data::sqlx08 / sqlx09 |
vld-diesel | vld-data, diesel + backend | vld_data::diesel |
vld-sea | vld-data, sea-orm-1 / sea-orm-2 (+ with-*) | vld_data::sea1 / sea2 |
vld-surrealdb | vld-data | vld_data::surrealdb |
vld-redis | vld-data, redis-0 / redis-1 (+ redis-aio, redis-aio-tokio) | vld_data::redis0 / redis1 |
vld-lapin | vld-data, lapin-2 / lapin-3 / lapin-4 | vld_data::lapin2 / lapin3 / lapin4 |
vld-config | vld-app, config-rs / figment | vld_app::config |
vld-clap | vld-app, clap | vld_app::clap |
vld-tauri | vld-app | vld_app::tauri |
vld-integration-common | vld | vld::form, vld::error::{format_path, flatten_issues} |
Former defaults you now have to name: vld-ntex → ntex-4, vld-utoipa → utoipa-5, vld-schemars / vld-aide → schemars-0, vld-sqlx → sqlx-0_8 + sqlite, vld-diesel → diesel + sqlite, vld-sea → sea-orm-1, vld-redis → redis-0, vld-lapin → lapin-2, vld-config → config-rs. vld-redis's aio / aio-tokio are redis-aio / redis-aio-tokio; vld-ntex's compress is ntex-compress.
Macros moved from the crate root to their module: vld_openapi::utoipa5::impl_to_schema!, vld_openapi::schemars1::impl_json_schema!, vld::ts::impl_to_zod!, vld::fake::impl_fake!, vld::form::validate_args!, vld_web::tonic::impl_validate!, vld_data::sea1::impl_vld_before_save!, vld_data::surrealdb::validate_fields! (full list in the changelog).
Cargo.toml
# 0.7
vld-axum = "0.7"
vld-actix = "0.7"
vld-sqlx = "0.7" # sqlx 0.8 + sqlite by default
vld-utoipa = "0.7" # utoipa 5 by default
vld-leptos = "0.7"
vld-ts = "0.7"
# 0.8
vld = { version = "0.8", features = ["ts"] }
vld-web = { version = "0.8", features = ["axum", "actix"] }
vld-data = { version = "0.8", features = ["sqlx-0_8", "sqlite"] }
vld-openapi = { version = "0.8", features = ["utoipa-5"] }
Imports
// 0.7 // 0.8
use vld_axum::{VldJson, VldQuery}; use vld_web::axum::{VldJson, VldQuery};
use vld_actix::{VldJson, VldBodyLimit}; use vld_web::actix::{VldJson, VldBodyLimit};
use vld_sqlx::prelude::*; use vld_data::sqlx08::prelude::*;
use vld_utoipa::impl_to_schema; use vld_openapi::utoipa5::impl_to_schema;
vld_utoipa::impl_to_schema!(User); vld_openapi::utoipa5::impl_to_schema!(User);
vld_leptos::validate_args! { .. } vld::form::validate_args! { .. }
vld_leptos::check_field(&v, &schema) vld::form::check_field(&v, &schema)
use vld_ts::{impl_to_zod, ToZod}; use vld::ts::{impl_to_zod, ToZod};
vld-leptos / vld-dioxus had a prelude; vld::form has none, import the items you use.
vld_data::lapin*: VldLapinError
VldLapinError is #[non_exhaustive] and has a new variant NotSettled: on lapin 3 / 4 an ack / nack / reject that sends nothing (delivery already settled, channel closed) is now an error instead of a silent Ok. Add a _ => arm to exhaustive matches.
0.6 → 0.7
vld-tauri: TauriIssue
TauriIssue has two new public fields, code (IssueCode::key()) and params (BTreeMap<String, String>). Struct literals must set them; deserializing old JSON still works (both default to empty).
TauriIssue { path, message, code: String::new(), params: Default::default() }
0.5 → 0.6
Regular expressions
regex-lite is no longer part of the public API: string().regex(Regex) / regex_msg and the vld::regex_lite re-export are gone. Use pattern (same regex feature, same issue code invalid_string / Regex, same JSON Schema pattern):
// before
vld::string().regex(vld::regex_lite::Regex::new(r"^[A-Z]{3}$").unwrap())
// after
vld::string().pattern(r"^[A-Z]{3}$")
// an invalid pattern you want to handle instead of panicking
vld::string().pattern(vld::rules::Pattern::new(src)?)
For checks that are easier in Rust than in a regex, see custom rules.
optional, nullable, nullish
nullable()fields are now required: an absent key fails withmissing_field(a presentnullis stillNone). Usenullish()where the key may be left out.optional()no longer addsnullto its JSON Schema (TypeScriptx?: T); parsing still acceptsnull.nullable()is inrequiredin JSON Schema (TypeScriptx: T | null).
See the table.
Unions serialize as plain values
Either / Either3 are serde untagged now: {"Left": "x"} becomes "x". Code that stored or sent the tagged form must use the bare value.
Removed
| Removed | Use |
|---|---|
features serialize, deserialize | nothing (serde support is always on): drop them from features |
ZFloat::finite() | nothing: JSON has no NaN / infinity |
ZObject::field_schema() | field() |
ZObject::deep_partial() | partial() on each nested object |
vld-actix::VldJsonError | VldActixError |
vld-diesel::validate_update, vld-sqlx::validate_update | validate_insert |
vld-surrealdb::validate_record | validate_content |
vld-http-common::ValidationIssueWithCode / format_issues_with_code | ValidationIssue / format_issues |
vld-http-common::format_json_parse_error / format_utf8_error | VldHttpError::parse (the adapters already answer with it) |
vld-tower::try_validated, vld-rama::try_validated | validated() |
vld-tauri::validate_event / validate_state / validate_plugin_config / validate_channel_message | validate |
impl_to_lapin!, impl_to_redis!, impl_to_redis_async! | LapinChannel::new(ch), RedisConn::new(conn), AsyncRedisConn::new(conn) |
vld-utoipa::impl_into_params!, impl_to_schema_query!, impl_to_schema_path! | #[into_params(parameter_in = ...)] + impl_to_schema!(T), or impl_to_schema!(T, query) |
Custom DynSchema impls
DynSchema has a new required method dyn_parse_missing (implemented for every VldSchema automatically). Only a hand-written DynSchema impl needs it: return what an absent object key should give.
0.4 → 0.5
See the 0.5.0 entry in the changelog (its "Migration from 0.4" section).