From cbd5806be7d7d52247d3a56dab240f043b8c1eab Mon Sep 17 00:00:00 2001 From: Daniel Bonofiglio Date: Tue, 23 Apr 2024 17:02:59 -0300 Subject: [PATCH] feat: implement `Validate` for `Cow` --- garde/src/validate.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/garde/src/validate.rs b/garde/src/validate.rs index bee9acd..587f0d5 100644 --- a/garde/src/validate.rs +++ b/garde/src/validate.rs @@ -331,3 +331,19 @@ impl Validate for Option { } } } + +impl<'a, B: Validate> Validate for std::borrow::Cow<'a, B> +where + B: ToOwned, +{ + type Context = B::Context; + + fn validate_into( + &self, + ctx: &Self::Context, + parent: &mut dyn FnMut() -> Path, + report: &mut Report, + ) { + self.as_ref().validate_into(ctx, parent, report) + } +}