Skip to main content

Crate vld_dioxus

Crate vld_dioxus 

Source
Expand description

§vld-dioxus — Dioxus integration for the vld validation library

Shared validation for Dioxus server functions and WASM clients. Define validation rules once, use them on both the server and the browser.

Zero dependency on dioxus — works with any Dioxus version (0.5, 0.6, 0.7+). Compatible with WASM and native targets.

§Key Features

FeatureDescription
validate_args!Inline validation of server function arguments
validate / validate_valueValidate a serializable value against a schema
check_fieldSingle-field validation for reactive UI
check_all_fieldsMulti-field validation returning per-field errors
VldServerErrorSerializable error type for server→client error transport

§Quick Example

// Shared validation rules (used on server AND client)
fn name_schema() -> vld::primitives::ZString { vld::string().min(2).max(50) }
fn email_schema() -> vld::primitives::ZString { vld::string().email() }

// Server function
#[server]
async fn create_user(name: String, email: String) -> Result<(), ServerFnError> {
    vld_dioxus::validate_args! {
        name  => name_schema(),
        email => email_schema(),
    }.map_err(|e| ServerFnError::new(e.to_string()))?;
    Ok(())
}

// Client component (reactive validation)
#[component]
fn CreateUserForm() -> Element {
    let mut name = use_signal(String::new);
    let name_err = use_memo(move || {
        vld_dioxus::check_field(&name(), &name_schema())
    });
    // ... render form with error display
}

Modules§

prelude
Prelude — import everything you need.

Macros§

validate_args
Validate server function arguments inline.

Structs§

FieldError
A single field validation error.
VldServerError
Structured validation error for Dioxus server functions.

Functions§

check_all_fields
Validate all fields of a serializable struct against a vld schema type.
check_field
Check a single value against a schema, returning an error message if invalid.
check_field_all
Check a single value, returning all error messages (not just the first).
validate
Validate a serializable value against a vld schema type.
validate_value
Validate a serde_json::Value against a vld schema type.