Skip to content

v0.15.0

Compare
Choose a tag to compare
@jprochazk jprochazk released this 09 Sep 11:33
· 132 commits to main since this release

Breaking changes

  • garde::error has been completely overhauled.
  • garde::Validate has a new validate_into method, which is the primary entrypoint for custom implementations now.
  • garde::Validate::validate is now implemented by default by calling validate_into.

These changes should not have any significant effects on the usage of the library, if all you're doing is deriving Validate and serializing errors using the Display implementation on Errors (now called Report). If you're having trouble migrating, please open an issue.

New features

You can now easily select! errors for specific fields on a given Report:

#[derive(garde::Validate)]
struct Foo<'a> {
  #[garde(dive)]
  bar: Bar<'a>,
}

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

let v = Foo { bar: Bar { value: "" } };
let report = v.validate(&()).unwrap_err();

println!("errors for `Foo.bar.value`");
for error in garde::error::select!(report, bar.value) {
  println!("{error}");
}

Pull requests

Full Changelog: v0.14.1...v0.15.0