pub struct ValidatedJson<T>(pub T);Expand description
ValidatedJson is an Axum extractor that behaves like Zod’s .parse().
It consumes the request body as JSON, parses it into type T, and immediately
calls .validate() on it. If validation fails, it throws a formatted 400 Bad Request error.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Clone> Clone for ValidatedJson<T>
impl<T: Clone> Clone for ValidatedJson<T>
impl<T: Copy> Copy for ValidatedJson<T>
Source§impl<T: Debug> Debug for ValidatedJson<T>
impl<T: Debug> Debug for ValidatedJson<T>
Source§impl<T: Default> Default for ValidatedJson<T>
impl<T: Default> Default for ValidatedJson<T>
Source§impl<T, S> FromRequest<S> for ValidatedJson<T>where
T: DeserializeOwned + Validate,
S: Send + Sync,
Json<T>: FromRequest<S, Rejection = JsonRejection>,
impl<T, S> FromRequest<S> for ValidatedJson<T>where
T: DeserializeOwned + Validate,
S: Send + Sync,
Json<T>: FromRequest<S, Rejection = JsonRejection>,
Auto Trait Implementations§
impl<T> Freeze for ValidatedJson<T>where
T: Freeze,
impl<T> RefUnwindSafe for ValidatedJson<T>where
T: RefUnwindSafe,
impl<T> Send for ValidatedJson<T>where
T: Send,
impl<T> Sync for ValidatedJson<T>where
T: Sync,
impl<T> Unpin for ValidatedJson<T>where
T: Unpin,
impl<T> UnsafeUnpin for ValidatedJson<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for ValidatedJson<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