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§
- Field
Result - Result of validating a single field.
- Issue
Builder - Fluent builder for constructing a single
ValidationIssue. - Parse
Result - Result of lenient parsing: contains the (possibly partial) struct and per-field diagnostics.
- Validation
Issue - 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 oncebase64(),base64url()orhex()is set. Built withvld::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 viavld::char(). - ZCustom
- Schema from a custom validation function.
- ZDefault
- Wraps a schema to provide a default value when the input is
nullor missing. - ZDescribe
- Wraps a schema with a human-readable description.
- ZDiscriminated
Union - Discriminated union: chooses a schema based on a discriminator field value.
- ZDuration
- Schema for
std::time::Duration. Created viavld::duration(). - ZEnum
- Schema for string enum validation. Created via
vld::enumeration(). - ZEnumOf
- Schema mapping fixed strings to values of
T. Created viavld::enum_of(). - ZF32
- Schema for
f32numbers. Created viavld::f32(). - ZFrom
Serde - Schema that deserializes the JSON value into any
T: DeserializeOwned. Created viavld::from_serde(). - ZFrom
Str - Schema that parses a JSON string with
T: FromStr. Created viavld::from_str(). - ZInteger
- Schema for a sized integer (
i8..u64,isize,usize). Created viavld::i8()…vld::u64();ZInt(vld::number().int()) isZInteger<i64>. - ZIntersection
- Intersection of two schemas: input must satisfy both.
- ZJson
Value - 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 aHashMap. - ZMessage
- Override the error message for an inner schema.
- ZNever
- Schema that rejects every value (
invalid_type, expectednever). Created viavld::never(). - ZNull
- Schema that accepts only
null. Created viavld::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 viavld::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 withwithin). - 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>) orvld::record_with_keys()(HashMap<K, V>);ordered()switches the output to aBTreeMap. - 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). - ZSocket
Addr - Schema for socket addresses (
ipv4:port/[ipv6]:port; hostnames are rejected). Created viavld::socket_addr(). - ZString
- Schema for string validation. Created via
vld::string(). - ZSuper
Refine - Refinement that can produce multiple errors at once.
- ZTransform
- Transforms the output of a schema after successful parsing.
- 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). - Issue
Code - Validation issue code — describes what went wrong.
- Path
Segment - A segment in a validation error path.
Traits§
- Into
Literal - Trait for types that can be used as literal values.
- Schema
- A schema with everything the enabled features need (here:
VldSchema; withopenapialso 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
VldErrorinto a simple field-based structure. - prettify_
error - Format a
VldErrorinto a human-readable string. - treeify_
error - Convert a
VldErrorinto a tree structure that mirrors the schema.
Type Aliases§
- ZInt
- Integer schema with
i64output. Created viavld::number().int(). - ZOrdered
Record - Record with
BTreeMapoutput (sorted keys); seeZRecord::ordered.