Keats / validator

Simple validation for Rust structs
MIT License
2.07k stars 151 forks source link

How to validate `Vec` and inner values? #353

Open t3ned opened 1 month ago

t3ned commented 1 month ago

Is it possible to validate the length of a Vec, and the inner value such as an integer?

Given this example, this Vec must have a length of 1-10, and the inner u32 must fall within the range of 1-100. The code below is invalid

#[derive(Debug, Deserialize, Validate)]
struct Data {
    #[validate(length(min = 1, max = 10), range(min = 1, max = 100))]
    ids: Vec<u32>
}
Keats commented 3 weeks ago

Not right now