impl HasValidateArgs for all extractors

This commit is contained in:
gengteng
2023-09-27 10:31:45 +08:00
parent 323d16c142
commit 5b15f15ce3
14 changed files with 147 additions and 32 deletions

View File

@@ -61,9 +61,9 @@
//! }
//! ```
use crate::HasValidate;
use crate::{HasValidate, HasValidateArgs};
use axum::TypedHeader;
use validator::Validate;
use validator::{Validate, ValidateArgs};
impl<T: Validate> HasValidate for TypedHeader<T> {
type Validate = T;
@@ -72,6 +72,13 @@ impl<T: Validate> HasValidate for TypedHeader<T> {
}
}
impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for TypedHeader<T> {
type ValidateArgs = T;
fn get_validate_args(&self) -> &Self::ValidateArgs {
&self.0
}
}
#[cfg(test)]
mod tests {
use crate::tests::{ValidTest, ValidTestParameter};