impl HasValidateArgs for all extractors
This commit is contained in:
@@ -47,9 +47,9 @@
|
||||
//! }
|
||||
//! ```
|
||||
|
||||
use crate::HasValidate;
|
||||
use crate::{HasValidate, HasValidateArgs};
|
||||
use axum_msgpack::{MsgPack, MsgPackRaw};
|
||||
use validator::Validate;
|
||||
use validator::{Validate, ValidateArgs};
|
||||
|
||||
impl<T: Validate> HasValidate for MsgPack<T> {
|
||||
type Validate = T;
|
||||
@@ -58,6 +58,13 @@ impl<T: Validate> HasValidate for MsgPack<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for MsgPack<T> {
|
||||
type ValidateArgs = T;
|
||||
fn get_validate_args(&self) -> &Self::ValidateArgs {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Validate> HasValidate for MsgPackRaw<T> {
|
||||
type Validate = T;
|
||||
fn get_validate(&self) -> &T {
|
||||
@@ -65,6 +72,13 @@ impl<T: Validate> HasValidate for MsgPackRaw<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'v, T: ValidateArgs<'v>> HasValidateArgs<'v> for MsgPackRaw<T> {
|
||||
type ValidateArgs = T;
|
||||
fn get_validate_args(&self) -> &Self::ValidateArgs {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::tests::{ValidTest, ValidTestParameter};
|
||||
|
||||
Reference in New Issue
Block a user