Skip to content

How to validate Vec and inner values? #353

@t3ned

Description

@t3ned

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>
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions