impl FromRef<()> for ValidationContext<()>

This commit is contained in:
gengteng
2023-09-27 19:09:54 +08:00
parent 8f1aab74c6
commit 359fa2e8ac

View File

@@ -182,7 +182,7 @@ impl ValidationContext<()> {
/// ///
/// fn custom_response(errors: ValidationErrors) -> Response { /// fn custom_response(errors: ValidationErrors) -> Response {
/// // return response with custom status code and body /// // return response with custom status code and body
/// (StatusCode::NOT_FOUND, Json(errors)).into_response() /// (StatusCode::IM_A_TEAPOT, Json(errors)).into_response()
/// } /// }
/// ///
/// let context = ValidationContext::custom(custom_response); /// let context = ValidationContext::custom(custom_response);
@@ -293,6 +293,12 @@ impl<Arguments> ValidationContext<Arguments> {
} }
} }
impl FromRef<()> for ValidationContext<()> {
fn from_ref(_: &()) -> Self {
ValidationContext::default()
}
}
/// `ValidError` is the error type returned when the `Valid` extractor fails. /// `ValidError` is the error type returned when the `Valid` extractor fails.
/// ///
/// It has two variants: /// It has two variants: