add support for validify
This commit is contained in:
@@ -114,6 +114,24 @@ impl<T: validify::Modify> crate::HasModify for Form<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "validify")]
|
||||
impl<T> crate::PayloadExtractor for Form<T> {
|
||||
type Payload = T;
|
||||
|
||||
fn get_payload(self) -> Self::Payload {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "validify")]
|
||||
impl<T: validify::Validify> crate::HasValidify for Form<T> {
|
||||
type Validify = T;
|
||||
type PayloadExtractor = Form<T::Payload>;
|
||||
fn from_validified(v: Self::Validify) -> Self {
|
||||
Form(v)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tests::{ValidTest, ValidTestParameter};
|
||||
|
||||
@@ -114,6 +114,25 @@ impl<T: validify::Modify> crate::HasModify for Query<T> {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "validify")]
|
||||
impl<T> crate::PayloadExtractor for Query<T> {
|
||||
type Payload = T;
|
||||
|
||||
fn get_payload(self) -> Self::Payload {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "validify")]
|
||||
impl<T: validify::Validify> crate::HasValidify for Query<T> {
|
||||
type Validify = T;
|
||||
type PayloadExtractor = Query<T::Payload>;
|
||||
|
||||
fn from_validified(v: Self::Validify) -> Self {
|
||||
Query(v)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tests::{ValidTest, ValidTestParameter};
|
||||
|
||||
@@ -97,10 +97,10 @@
|
||||
|
||||
#[cfg(feature = "garde")]
|
||||
use crate::Garde;
|
||||
#[cfg(feature = "validify")]
|
||||
use crate::{Modified, Validated, ValidifiedByRef};
|
||||
#[cfg(feature = "validator")]
|
||||
use crate::{Valid, ValidEx};
|
||||
#[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", feature = "validify"))]
|
||||
@@ -127,6 +127,11 @@ impl<T: TypedPath + Display> TypedPath for Validated<T> {
|
||||
}
|
||||
|
||||
#[cfg(feature = "validify")]
|
||||
impl<T: TypedPath + Display> TypedPath for Validified<T> {
|
||||
impl<T: TypedPath + Display> TypedPath for Modified<T> {
|
||||
const PATH: &'static str = T::PATH;
|
||||
}
|
||||
|
||||
#[cfg(feature = "validify")]
|
||||
impl<T: TypedPath + Display> TypedPath for ValidifiedByRef<T> {
|
||||
const PATH: &'static str = T::PATH;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user