Crates.io | validatron_derive |
lib.rs | validatron_derive |
version | 0.5.0 |
source | src |
created_at | 2021-01-07 15:53:45.762126 |
updated_at | 2022-10-18 09:28:54.683642 |
description | A data structure validation library designed for user input |
homepage | |
repository | https://github.com/nsat/validatron |
max_upload_size | |
id | 333781 |
size | 13,388 |
Validatron is a data structure validation library for Rust that is designed for performing extensive integrity checks on user supplied data prior to use.
It is heavily inspired by the keats/validator crate but with different design choices:
(Check the examples directory for additional examples.)
use validatron::Validate;
#[derive(Debug, Validate)]
struct MyStruct {
#[validatron(min = 42)]
a: i64,
#[validatron(max_len = 5)]
b: Vec<u32>,
}
fn main() {
let good = MyStruct {
a: 666,
b: vec![],
};
assert!(good.validate().is_ok());
let bad = MyStruct {
a: 1,
b: vec![42; 25],
};
let result = bad.validate();
assert!(result.is_err());
println!("{:#?}", result);
}
validatron
is licensed under the MIT license; see the LICENSE file for more details.