remove redundant trait bound; add support for validify

This commit is contained in:
gengteng
2023-10-17 10:57:26 +08:00
parent 72dc8142d2
commit 61bf3c5b23
20 changed files with 1482 additions and 32 deletions

View File

@@ -105,6 +105,15 @@ impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for Form<T> {
}
}
#[cfg(feature = "validify")]
impl<T: validify::Modify> crate::HasModify for Form<T> {
type Modify = T;
fn get_modify(&mut self) -> &mut Self::Modify {
&mut self.0
}
}
#[cfg(test)]
mod tests {
use crate::tests::{ValidTest, ValidTestParameter};

View File

@@ -109,6 +109,15 @@ impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for Protobuf<T> {
}
}
#[cfg(feature = "validify")]
impl<T: validify::Modify> crate::HasModify for Protobuf<T> {
type Modify = T;
fn get_modify(&mut self) -> &mut Self::Modify {
&mut self.0
}
}
#[cfg(test)]
mod tests {
use crate::tests::{ValidTest, ValidTestParameter};

View File

@@ -105,6 +105,15 @@ impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for Query<T> {
}
}
#[cfg(feature = "validify")]
impl<T: validify::Modify> crate::HasModify for Query<T> {
type Modify = T;
fn get_modify(&mut self) -> &mut Self::Modify {
&mut self.0
}
}
#[cfg(test)]
mod tests {
use crate::tests::{ValidTest, ValidTestParameter};

View File

@@ -99,9 +99,11 @@
use crate::Garde;
#[cfg(feature = "validator")]
use crate::{Valid, ValidEx};
#[cfg(any(feature = "validator", feature = "garde"))]
#[cfg(feature = "validify")]
use crate::{Validated, Validified};
#[cfg(any(feature = "validator", feature = "garde", feature = "validify"))]
use axum_extra::routing::TypedPath;
#[cfg(any(feature = "validator", feature = "garde"))]
#[cfg(any(feature = "validator", feature = "garde", feature = "validify"))]
use std::fmt::Display;
#[cfg(feature = "validator")]
@@ -118,3 +120,13 @@ impl<T: TypedPath + Display, A> TypedPath for ValidEx<T, A> {
impl<T: TypedPath + Display> TypedPath for Garde<T> {
const PATH: &'static str = T::PATH;
}
#[cfg(feature = "validify")]
impl<T: TypedPath + Display> TypedPath for Validated<T> {
const PATH: &'static str = T::PATH;
}
#[cfg(feature = "validify")]
impl<T: TypedPath + Display> TypedPath for Validified<T> {
const PATH: &'static str = T::PATH;
}