Bump version to 0.8.0

This commit is contained in:
gengteng
2023-09-19 22:42:17 +08:00
parent 9769c1a4eb
commit 600dfcd92a
5 changed files with 55 additions and 18 deletions

View File

@@ -1,18 +1,29 @@
//! # Support for `Cached<T>` and `WithRejection<T, R>`
//! # Support for extractors from `axum-extra`
//!
//! ## Feature
//!
//! Enable the `extra` feature to use `Valid<Cached<T>>`, `Valid<WithRejection<T, R>>` and `WithRejection<Valid<T>, R>`.
//!
//! ## `Valid<Cached<T>>`
//! ## Modules
//!
//! ### Usage
//! * [`self`] : `Cache<T>`
//! * [`self`] : `WithRejection<T, R>`
//! * [`form`] : `Form<T>`
//! * [`protobuf`] : `Protobuf<T>`
//! * [`query`] : `Query<T>`
//! * [`typed_path`] : `T: TypedPath`
//!
//! ## `Cached<T>` and `WithRejection<T, R>`
//!
//! ### `Valid<Cached<T>>`
//!
//! #### Usage
//!
//! 0. Implement your own extractor `T`.
//! 1. Implement `Clone` and `Validate` for your extractor type `T`.
//! 2. In your handler function, use `Valid<Cached<T>>` as some parameter's type.
//!
//! ### Example
//! #### Example
//!
//! ```no_run
//! use axum::extract::FromRequestParts;
@@ -63,15 +74,15 @@
//! }
//! ```
//!
//! ## `Valid<WithRejection<T, R>>`
//! ### `Valid<WithRejection<T, R>>`
//!
//! ### Usage
//! #### Usage
//!
//! 0. Implement your own extractor `T` and rejection type `R`.
//! 1. Implement `Validate` for your extractor type `T`.
//! 2. In your handler function, use `Valid<WithRejection<T, R>>` as some parameter's type.
//!
//! ### Example
//! #### Example
//!
//! ```no_run
//! use axum::extract::FromRequestParts;
@@ -128,16 +139,16 @@
//! }
//! ```
//!
//! ## `WithRejection<Valid<T>, R>`
//! ### `WithRejection<Valid<T>, R>`
//!
//! ### Usage
//! #### Usage
//!
//! 0. Implement your own extractor `T` and rejection type `R`.
//! 1. Implement `Validate` and `HasValidate` for your extractor type `T`.
//! 2. Implement `From<ValidRejection<T::Rejection>>` for `R`.
//! 3. In your handler function, use `WithRejection<Valid<T>, R>` as some parameter's type.
//!
//! ### Example
//! #### Example
//!
//! ```no_run
//! use axum::extract::FromRequestParts;

View File

@@ -38,7 +38,17 @@ pub const VALIDATION_ERROR_STATUS: StatusCode = StatusCode::UNPROCESSABLE_ENTITY
#[cfg(not(feature = "422"))]
pub const VALIDATION_ERROR_STATUS: StatusCode = StatusCode::BAD_REQUEST;
/// Valid entity extractor
/// # `Valid` data extractor
///
/// This extractor can be used in combination with axum's extractors like
/// Json, Form, Query, Path, etc to validate their inner data automatically.
/// It can also work with custom extractors that implement the `HasValidate` trait.
///
/// See the docs for each integration module to find examples of using
/// `Valid` with that extractor:
///
/// For examples with custom extractors, check out the `tests/custom.rs` file.
///
#[derive(Debug, Clone, Copy, Default)]
pub struct Valid<E>(pub E);