jprochazk / garde

A powerful validation library for Rust
Apache License 2.0
455 stars 27 forks source link

Remove unnecessary colon inside a validation error of a newtype pattern #87

Closed dpytaylo closed 8 months ago

dpytaylo commented 8 months ago

Could we remove a colon from a tuple struct (newtype pattern) with #[garde(transperent)?

For an example:

use garde::Validate;

#[derive(garde::Validate)]
#[garde(transparent)]
struct Username(
    #[garde(length(max = 50))]
    String,
);

fn main() {
    let a = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
    println!("{}", Username(a.into()).validate(&()).unwrap_err().to_string());
}

This code will print this:

: length is greater than 50

I suppose that without a colon, this error message might look better.