Skip to content

v0.19.0

Compare
Choose a tag to compare
@jprochazk jprochazk released this 09 Jun 17:30
· 23 commits to main since this release

What's Changed

Validate without context

Previously, validate always required a context parameter, even if it was not actually used. In #102, @lasantosr split the validate function into validate and validate_with, where the former does not require a Context parameter if Context implements Default.

#[derive(garde::Validate)]
struct Foo<'a> {
    #[garde(length(min = 1))]
    bar: &'a str,
}

Foo { bar: "test" }.validate() // no more `&()`!

Add field matching rule

@darkenmay added a new matches rule in #110, which adds support for the basic case of matching one field against another in the same struct:

#[derive(garde::Validate)]
struct User<'a> {
    #[garde(length(min = 1))]
    password: &'a str,
    #[garde(matches(password))] // checks if this field equals `password`.
    password2: &'a str,
}

User { password: "ferris123", password2: "ferris123" }.validate() 

Note that this currently does not work for enums.

Other improvements

New Contributors

Full Changelog: v0.18.0...v0.19.0