validate-tools 0.1.0
Composable validators for strings and numbers that collect every error, plus a per-field report
Install
cargo add validate-tools --registry rupm
In Ruststudio: Packages, search for validate-tools, Install.
Owner: Rust Studio. Licence: MIT OR Apache-2.0. Total downloads: 0. Published 2026-11-22.
Versions
- 0.1.0 2026-11-22
README
# validate-tools
Composable validators for strings and numbers that collect every error, plus a per-field report
Add it with `rupm add validate-tools` (or `cargo add validate-tools --registry rupm`).
```rust
use validate_tools::{number, string, Report};
let username = string().not_empty().min_len(3).alphanumeric();
let age = number::<u32>().between(18, 120);
let mut report = Report::new();
report.field("username", "a!", &username);
report.field("age", &15, &age);
assert!(!report.is_ok());
assert_eq!(report.errors_for("username").count(), 2); // too short, not alphanumeric
assert_eq!(report.errors_for("age").next().unwrap().message, "must be between 18 and 120");
```