Rust

Crate root

Module
What utopia_validators defines at its root.

Modules

Contents

use utopia_validators::Verdict;
Rust
pub struct Verdict

The 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 Type

The type of value a validator expects.

use utopia_validators::Validator;
Rust
pub trait Validator: Send + Sync

A 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) -> String

Formats an integer with commas between thousands and no decimals: 3600 is 3,600.