Keats / validator

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

Create one message if length is too short and a different message if too long #360

Open Pi-Cla opened 1 week ago

Pi-Cla commented 1 week ago

When I tried to update past 0.16 I now have a "Duplicate field length" bug when I try to use duplicate fields like so:

#[validate(
        length(min = 1, message = "cannot be empty"),
        length(max = 32, message = "must be <= 32 characters")
    )]
    pub name: String,

where I intentionally use two different length checks to create two different messages.

Is there a way to still create two different messages or will I have to just combine them into one message like: "string was empty or had more than 32 characters"?

Keats commented 6 days ago

The messages should be dynamic depending on whether min/max/equal are set really