Refactor: Split HasValidate implementations for four different extractors into multiple files and export them using feature flags

This commit is contained in:
gengteng
2023-07-21 21:01:10 +08:00
parent 845b81d134
commit 295ae17697
8 changed files with 111 additions and 61 deletions

21
src/form.rs Normal file
View File

@@ -0,0 +1,21 @@
//! # Implementation of the `HasValidate` trait for the `Form` extractor.
//!
use crate::{HasValidate, ValidRejection};
use axum::extract::rejection::FormRejection;
use axum::Form;
use validator::Validate;
impl<T: Validate> HasValidate for Form<T> {
type Validate = T;
type Rejection = FormRejection;
fn get_validate(&self) -> &T {
&self.0
}
}
impl From<FormRejection> for ValidRejection<FormRejection> {
fn from(value: FormRejection) -> Self {
Self::Inner(value)
}
}