Modules
composeValidators made of other validators.errorThe error a validator returns when a value cannot be validated or described, or when a constructor refuses its arguments.hostnameHost names checked against an allow list, alone or as the host of a URL.inputThe values validators read: a request value or an exact value, borrowed, and a one-level view of either.jsonJSON validators: any JSON value, JSON arrays, JSON objects, and Firebase Cloud Messaging credentials.listLists, maps, allowed values and optional values.networkDomain names, IP addresses and URLs.scalarBooleans, integers, floats, numbers and numeric ranges.stringString validators: substrings, globs, colors and phone numbers.textStrings of bounded length, and identifiers.
Contents
use utopia_validators::Verdict;Rust
pub struct VerdictThe outcome of one validation.
Besides validity, a verdict carries the description to report for the value and, for a composite, which rule decided.
use utopia_validators::Type;Rust
pub enum TypeThe type of value a validator expects.
use utopia_validators::Validator;Rust
pub trait Validator: Send + SyncA parameter validator: decides whether a value is valid, and describes the rule it follows.
Implement Validator::description and Validator::is_valid for a
validator of request values (Value); the provided
Validator::validate then accepts exact values too, through their
request-model form. The validators of this crate implement
Validator::validate for both models.
use utopia_validators::number_format;Rust
pub fn number_format(n: i128) -> StringFormats an integer with commas between thousands and no decimals: 3600
is 3,600.