[−][src]Struct vale::Valid
A struct that can be used in Rocket
routes. If you have some type that implements Validate
,
you can designate in your controller that you want to have a validated instance of that type.
Example
use vale::Valid; #[rocket::post("/user", data = "<user>")] fn update_user(user: Valid<User>) { // user is now validated, this code is not reached if the validation failed }
It is also possible to nest this type with other wrappers:
#[rocket::post("/user", data = "<user>")] fn update_user(user: Valid<Json<User>>) { let user = user.into_inner().into_inner(); }
Features
Requires the rocket
feature to be enabled
Implementations
impl<T: Validate> Valid<T>
[src]
pub fn into_inner(self) -> T
[src]
Consumes the Valid
wrapper and returns the inner item.
Trait Implementations
impl<T: Validate> Deref for Valid<T>
[src]
impl<T: Validate> DerefMut for Valid<T>
[src]
impl<'a, T: 'a> FromData<'a> for Valid<T> where
T: FromData<'a> + Validate,
[src]
T: FromData<'a> + Validate,
type Error = ValidationError<T::Error>
The associated error to be returned when the guard fails.
type Owned = T::Owned
The owned type returned from FromData::transform()
. Read more
type Borrowed = T::Borrowed
The borrowed type consumed by FromData::from_data()
when
FromData::transform()
returns a Transform::Borrowed
. Read more
fn transform(
r: &Request<'_>,
d: Data
) -> Transform<Outcome<Self::Owned, Self::Error>>
[src]
r: &Request<'_>,
d: Data
) -> Transform<Outcome<Self::Owned, Self::Error>>
fn from_data(
r: &Request<'_>,
o: Transformed<'a, Self>
) -> Outcome<Self, Self::Error>
[src]
r: &Request<'_>,
o: Transformed<'a, Self>
) -> Outcome<Self, Self::Error>
Auto Trait Implementations
impl<T> RefUnwindSafe for Valid<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Valid<T> where
T: Send,
T: Send,
impl<T> Sync for Valid<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Valid<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Valid<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, I> AsResult<T, I> for T where
I: Input,
I: Input,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<'a, T> FromData<'a> for T where
T: FromDataSimple,
[src]
T: FromDataSimple,
type Error = <T as FromDataSimple>::Error
The associated error to be returned when the guard fails.
type Owned = Data
The owned type returned from FromData::transform()
. Read more
type Borrowed = Data
The borrowed type consumed by FromData::from_data()
when
FromData::transform()
returns a Transform::Borrowed
. Read more
pub fn transform(
&Request<'_>,
d: Data
) -> Transform<Outcome<<T as FromData<'a>>::Owned, (Status, <T as FromData<'a>>::Error), Data>, Outcome<<T as FromData<'a>>::Owned, (Status, <T as FromData<'a>>::Error), Data>>
[src]
&Request<'_>,
d: Data
) -> Transform<Outcome<<T as FromData<'a>>::Owned, (Status, <T as FromData<'a>>::Error), Data>, Outcome<<T as FromData<'a>>::Owned, (Status, <T as FromData<'a>>::Error), Data>>
pub fn from_data(
req: &Request<'_>,
o: Transform<Outcome<<T as FromData<'a>>::Owned, (Status, <T as FromData<'a>>::Error), Data>, Outcome<&'a <T as FromData<'a>>::Borrowed, (Status, <T as FromData<'a>>::Error), Data>>
) -> Outcome<T, (Status, <T as FromData<'a>>::Error), Data>
[src]
req: &Request<'_>,
o: Transform<Outcome<<T as FromData<'a>>::Owned, (Status, <T as FromData<'a>>::Error), Data>, Outcome<&'a <T as FromData<'a>>::Borrowed, (Status, <T as FromData<'a>>::Error), Data>>
) -> Outcome<T, (Status, <T as FromData<'a>>::Error), Data>
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> IntoCollection<T> for T
pub fn into_collection<A>(self) -> SmallVec<A> where
A: Array<Item = T>,
A: Array<Item = T>,
pub fn mapped<U, F, A>(self, f: F) -> SmallVec<A> where
A: Array<Item = U>,
F: FnMut(T) -> U,
A: Array<Item = U>,
F: FnMut(T) -> U,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Typeable for T where
T: Any,
T: Any,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T, U> Validate for U where
T: Validate,
U: Deref<Target = T> + DerefMut,
[src]
T: Validate,
U: Deref<Target = T> + DerefMut,