This commit is contained in:
gengteng
2023-10-08 14:34:26 +08:00
parent 2f1aa1060f
commit dd68fe6131
19 changed files with 489 additions and 382 deletions

View File

@@ -38,8 +38,11 @@
//! }
//! ```
use crate::{HasValidate, HasValidateArgs};
use crate::HasValidate;
#[cfg(feature = "validator")]
use crate::HasValidateArgs;
use axum_extra::extract::Form;
#[cfg(feature = "validator")]
use validator::ValidateArgs;
impl<T> HasValidate for Form<T> {
@@ -49,6 +52,7 @@ impl<T> HasValidate for Form<T> {
}
}
#[cfg(feature = "validator")]
impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for Form<T> {
type ValidateArgs = T;
fn get_validate_args(&self) -> &Self::ValidateArgs {

View File

@@ -40,8 +40,11 @@
//! }
//! ```
use crate::{HasValidate, HasValidateArgs};
use crate::HasValidate;
#[cfg(feature = "validator")]
use crate::HasValidateArgs;
use axum_extra::protobuf::Protobuf;
#[cfg(feature = "validator")]
use validator::ValidateArgs;
impl<T> HasValidate for Protobuf<T> {
@@ -51,6 +54,7 @@ impl<T> HasValidate for Protobuf<T> {
}
}
#[cfg(feature = "validator")]
impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for Protobuf<T> {
type ValidateArgs = T;
fn get_validate_args(&self) -> &Self::ValidateArgs {

View File

@@ -41,8 +41,11 @@
//! }
//! ```
use crate::{HasValidate, HasValidateArgs};
use crate::HasValidate;
#[cfg(feature = "validator")]
use crate::HasValidateArgs;
use axum_extra::extract::Query;
#[cfg(feature = "validator")]
use validator::ValidateArgs;
impl<T> HasValidate for Query<T> {
@@ -52,6 +55,7 @@ impl<T> HasValidate for Query<T> {
}
}
#[cfg(feature = "validator")]
impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for Query<T> {
type ValidateArgs = T;
fn get_validate_args(&self) -> &Self::ValidateArgs {

View File

@@ -49,19 +49,26 @@
//! }
//! ```
use crate::garde::Garde;
#[cfg(feature = "garde")]
use crate::Garde;
#[cfg(feature = "validator")]
use crate::{Valid, ValidEx};
#[cfg(any(feature = "validator", feature = "garde"))]
use axum_extra::routing::TypedPath;
#[cfg(any(feature = "validator", feature = "garde"))]
use std::fmt::Display;
#[cfg(feature = "validator")]
impl<T: TypedPath + Display> TypedPath for Valid<T> {
const PATH: &'static str = T::PATH;
}
#[cfg(feature = "validator")]
impl<T: TypedPath + Display, A> TypedPath for ValidEx<T, A> {
const PATH: &'static str = T::PATH;
}
#[cfg(feature = "garde")]
impl<T: TypedPath + Display> TypedPath for Garde<T> {
const PATH: &'static str = T::PATH;
}