Registry / utility / validator

validator

JSON →
library0.20.0rscratesunverified

Common validation functions (email, url, length, ...) and trait to be used with `validator_derive`.

# Cargo.toml [dependencies] validator = "0.20.0"
INSTALL
IMPORT
SIG · VALIDATOR
V
validator
utilityrustv0.20.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Validate
use validator::Validate;

Validates a struct with email and length constraints.

use validator::Validate; #[derive(Validate)] struct Signup { #[validate(email)] email: String, #[validate(length(min = 8))] password: String, } fn main() { let s = Signup { email: "invalid".into(), password: "short".into() }; match s.validate() { Ok(_) => println!("valid"), Err(e) => println!("errors: {:?}", e), } }
Debug
Known issues
gotchaThe `Validate` derive macro requires the `validator_derive` crate as a separate dependency.
fix
Add `validator_derive` to your Cargo.toml with the same version as `validator`.
affects: >=0.20.0
Upgrade
Version history
0.20.0latest on crates.io
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
validator — cargo add validator · libregistry