v0.19.0
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
- Add Report::into_inner by @lasantosr in #107
- feat: implement
Validate
forCow
by @bonofiglio in #108
New Contributors
- @lasantosr made their first contribution in #102
- @darkenmay made their first contribution in #110
Full Changelog: v0.18.0...v0.19.0