Skip to main content

Module prelude

Module prelude 

Source
Expand description

Common imports: the sqlx wrappers plus vld::prelude.

Re-exports§

pub use crate::Validated;
pub use crate::VldBool;
pub use crate::VldFloat;
pub use crate::VldInt;
pub use crate::VldSqlxError;
pub use crate::VldText;
pub use crate::validate_insert;
pub use crate::validate_row;
pub use crate::validate_rows;

Structs§

FieldResult
Result of validating a single field.
IssueBuilder
Fluent builder for constructing a single ValidationIssue.
ParseResult
Result of lenient parsing: contains the (possibly partial) struct and per-field diagnostics.
ValidationIssue
A single validation issue with path, message and received value.
VldError
Collection of validation errors.
ZAny
Schema that accepts any JSON value. Created via vld::any().
ZArray
Schema for array validation. Created via vld::array().
ZBoolean
Schema for boolean validation. Created via vld::boolean().
ZBytes
Schema for binary data: a JSON array of byte values (0..=255), or a string once base64(), base64url() or hex() is set. Built with vld::bytes().
ZCatch
Wraps a schema with a fallback value returned on ANY validation error.
ZChar
Schema for a single char: a JSON string of exactly one Unicode scalar value. Created via vld::char().
ZCustom
Schema from a custom validation function.
ZDefault
Wraps a schema to provide a default value when the input is null or missing.
ZDescribe
Wraps a schema with a human-readable description.
ZDiscriminatedUnion
Discriminated union: chooses a schema based on a discriminator field value.
ZDuration
Schema for std::time::Duration. Created via vld::duration().
ZEnum
Schema for string enum validation. Created via vld::enumeration().
ZEnumOf
Schema mapping fixed strings to values of T. Created via vld::enum_of().
ZF32
Schema for f32 numbers. Created via vld::f32().
ZFromSerde
Schema that deserializes the JSON value into any T: DeserializeOwned. Created via vld::from_serde().
ZFromStr
Schema that parses a JSON string with T: FromStr. Created via vld::from_str().
ZInteger
Schema for a sized integer (i8..u64, isize, usize). Created via vld::i8() … vld::u64(); ZInt (vld::number().int()) is ZInteger<i64>.
ZIntersection
Intersection of two schemas: input must satisfy both.
ZJsonValue
Schema for any JSON value, with optional shape checks. Built with vld::json_value().
ZLazy
Lazy schema for recursive/self-referencing data structures.
ZLiteral
Schema for exact value matching. Created via vld::literal().
ZMap
Schema for validating a JSON array of [key, value] pairs into a HashMap.
ZMessage
Override the error message for an inner schema.
ZNever
Schema that rejects every value (invalid_type, expected never). Created via vld::never().
ZNull
Schema that accepts only null. Created via vld::null().
ZNullable
Wraps a schema to allow null.
ZNullish
Wraps a schema to make it both optional and nullable (nullish).
ZNumber
Schema for number validation (f64). Created via vld::number().
ZObject
Dynamic object schema with runtime-defined fields.
ZOptional
Wraps a schema to make it optional.
ZPath
Schema for filesystem paths. Created via vld::path() (read its security note: confine untrusted paths with within).
ZPipe
Chains two schemas: output of the first is serialized to JSON, then parsed by the second.
ZPreprocess
Applies a preprocessing function to the JSON value before validation.
ZRecord
Schema for validating JSON objects as key-value records. Created via vld::record() (HashMap<String, V>) or vld::record_with_keys() (HashMap<K, V>); ordered() switches the output to a BTreeMap.
ZRefine
Adds a custom refinement check to a schema without changing its output type.
ZSet
Schema for validating a JSON array into a HashSet (unique elements).
ZSocketAddr
Schema for socket addresses (ipv4:port / [ipv6]:port; hostnames are rejected). Created via vld::socket_addr().
ZString
Schema for string validation. Created via vld::string().
ZSuperRefine
Refinement that can produce multiple errors at once.
ZTransform
Transforms the output of a schema after successful parsing.
ZTryTransform
Transforms the output with a fallible function: an Err becomes a validation issue (IssueCode::Custom { code: "transform" }, the error’s text as the message).
ZUnion2
Union of two schemas. Tries the first, then the second.
ZUnion3
Union of three schemas.

Enums§

Either
A value that can be one of two types.
Either3
A value that can be one of three types (serialized untagged, like Either).
IssueCode
Validation issue code — describes what went wrong.
PathSegment
A segment in a validation error path.

Traits§

IntoLiteral
Trait for types that can be used as literal values.
Schema
A schema with everything the enabled features need (here: VldSchema; with openapi also the JSON Schema traits).
VldInput
Trait for types that can be used as input to schema parsing.
VldParse
Trait for types that can be parsed from a serde_json::Value.
VldSchema
Core validation schema trait.

Functions§

flatten_error
Flatten a VldError into a simple field-based structure.
prettify_error
Format a VldError into a human-readable string.
treeify_error
Convert a VldError into a tree structure that mirrors the schema.

Type Aliases§

ZInt
Integer schema with i64 output. Created via vld::number().int().
ZOrderedRecord
Record with BTreeMap output (sorted keys); see ZRecord::ordered.