pub struct Validated<T>(pub T);
Expand description
A validated extactor.
This type will run any validations on the inner extractors.
use actix_web::{post, web::{self, Json}, App};
use serde::Deserialize;
use validator::Validate;
use actix_web_validation::validator::Validated;
#[derive(Debug, Deserialize, Validate)]
struct Info {
#[validate(length(min = 5))]
username: String,
}
#[post("/")]
async fn index(info: Validated<Json<Info>>) -> String {
format!("Welcome {}!", info.username)
}
Tuple Fields§
§0: T
Implementations§
Source§impl<T> Validated<T>
impl<T> Validated<T>
pub fn into_inner(self) -> T
Trait Implementations§
Source§impl<T> FromRequest for Validated<T>
impl<T> FromRequest for Validated<T>
Source§type Future = ValidatedFut<T>
type Future = ValidatedFut<T>
Future that resolves to a
Self
. Read moreSource§fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future
fn from_request(req: &HttpRequest, payload: &mut Payload) -> Self::Future
Create a
Self
from request parts asynchronously.Auto Trait Implementations§
impl<T> Freeze for Validated<T>where
T: Freeze,
impl<T> RefUnwindSafe for Validated<T>where
T: RefUnwindSafe,
impl<T> Send for Validated<T>where
T: Send,
impl<T> Sync for Validated<T>where
T: Sync,
impl<T> Unpin for Validated<T>where
T: Unpin,
impl<T> UnwindSafe for Validated<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more