https://github.com/nsat/validatron
Rust data structure validation library designed for large user inputs
https://github.com/nsat/validatron
proc-macro rust serde validation
Last synced: 4 months ago
JSON representation
Rust data structure validation library designed for large user inputs
- Host: GitHub
- URL: https://github.com/nsat/validatron
- Owner: nsat
- License: mit
- Created: 2020-11-18T13:35:36.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-08-30T18:11:29.000Z (over 2 years ago)
- Last Synced: 2025-03-27T07:48:02.720Z (11 months ago)
- Topics: proc-macro, rust, serde, validation
- Language: Rust
- Homepage: https://github.com/nsat/validatron
- Size: 78.1 KB
- Stars: 4
- Watchers: 5
- Forks: 1
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Codeowners: CODEOWNERS
Awesome Lists containing this project
README
# Validatron [![Build Status]][actions] [![Docs]][docs.rs] [![Latest Version]][crates.io]
[Build Status]: https://img.shields.io/github/workflow/status/nsat/validatron/Rust/master
[actions]: https://github.com/nsat/validatron/actions?query=branch%3Amaster
[Docs]: https://docs.rs/validatron/badge.svg
[docs.rs]: https://docs.rs/validatron/
[Latest Version]: https://img.shields.io/crates/v/validatron.svg
[crates.io]: https://crates.io/crates/validatron
**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][1] crate but with different design choices:
- do not fail fast, return as many errors as possible
- return a serializable error type
- provide easily extendable validators
## Example
(Check the [examples](/validatron/examples) directory for additional examples.)
```rust
use validatron::Validate;
#[derive(Debug, Validate)]
struct MyStruct {
#[validatron(min = 42)]
a: i64,
#[validatron(max_len = 5)]
b: Vec,
}
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);
}
```
## License
`validatron` is licensed under the MIT license; see the [LICENSE](./LICENSE) file for more details.
[1]: https://github.com/Keats/validator