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

@@ -8,6 +8,16 @@
### Fixed ### Fixed
## axum-valid 0.8.0 (2023-09-19)
### Added
* Upgraded `axum-extra` dependencies to version 0.8.0
### Changed
### Fixed
## axum-valid 0.7.0 (2023-09-12) ## axum-valid 0.7.0 (2023-09-12)
### Added ### Added

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "axum-valid" name = "axum-valid"
version = "0.7.0" version = "0.8.0"
description = "Provide validator extractor for your axum application." description = "Provide validator extractor for your axum application."
authors = ["GengTeng <me@gteng.org>"] authors = ["GengTeng <me@gteng.org>"]
license = "MIT" license = "MIT"
@@ -24,8 +24,8 @@ edition = "2021"
features = ["all_types"] features = ["all_types"]
[dependencies] [dependencies]
axum = { version = "0.6.18", default-features = false } axum = { version = "0.6.20", default-features = false }
validator = "0.16.0" validator = "0.16.1"
[dependencies.axum_typed_multipart] [dependencies.axum_typed_multipart]
version = "0.9.0" version = "0.9.0"
@@ -43,7 +43,7 @@ default-features = false
optional = true optional = true
[dependencies.axum-extra] [dependencies.axum-extra]
version = "0.7.6" version = "0.8.0"
default-features = false default-features = false
optional = true optional = true
@@ -58,7 +58,7 @@ validator = { version = "0.16.0", features = ["derive"] }
serde_json = "1.0.104" serde_json = "1.0.104"
serde_yaml = "0.9.25" serde_yaml = "0.9.25"
mime = "0.3.17" mime = "0.3.17"
prost = "0.11.9" prost = "0.12.1"
once_cell = "1.18.0" once_cell = "1.18.0"
rmp-serde = "1.1.2" rmp-serde = "1.1.2"

View File

@@ -21,7 +21,8 @@ use validator::Validate;
use serde::Deserialize; use serde::Deserialize;
use axum_valid::Valid; use axum_valid::Valid;
use axum::extract::Query; use axum::extract::Query;
use axum::Json; use axum::{Json, Router};
use axum::routing::{get, post};
#[derive(Debug, Validate, Deserialize)] #[derive(Debug, Validate, Deserialize)]
pub struct Pager { pub struct Pager {
@@ -59,7 +60,7 @@ async fn main() -> anyhow::Result<()> {
When validation errors occur, the extractor will automatically return 400 with validation errors as the HTTP message body. When validation errors occur, the extractor will automatically return 400 with validation errors as the HTTP message body.
To see how each extractor can be used with `Valid`, please refer to the example in the [documentation](#modules) of the corresponding module. To see how each extractor can be used with `Valid`, please refer to the example in the [documentation](https://docs.rs/axum-valid) of the corresponding module.
## Features ## Features
@@ -84,6 +85,11 @@ To see how each extractor can be used with `Valid`, please refer to the example
| into_json | Validation errors will be serialized into JSON format and returned as the HTTP body | ❌ | ✅ | ✅ | | into_json | Validation errors will be serialized into JSON format and returned as the HTTP body | ❌ | ✅ | ✅ |
| full | Enables all features | ❌ | ✅ | ✅ | | full | Enables all features | ❌ | ✅ | ✅ |
## Compatibility
* axum-valid 0.7.x works with axum-extra v0.7.x
* axum-valid 0.8.x works with axum-extra v0.8.x
## License ## License
This project is licensed under the MIT License. This project is licensed under the MIT License.

View File

@@ -1,18 +1,29 @@
//! # Support for `Cached<T>` and `WithRejection<T, R>` //! # Support for extractors from `axum-extra`
//! //!
//! ## Feature //! ## Feature
//! //!
//! Enable the `extra` feature to use `Valid<Cached<T>>`, `Valid<WithRejection<T, R>>` and `WithRejection<Valid<T>, R>`. //! 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`. //! 0. Implement your own extractor `T`.
//! 1. Implement `Clone` and `Validate` for your extractor type `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. //! 2. In your handler function, use `Valid<Cached<T>>` as some parameter's type.
//! //!
//! ### Example //! #### Example
//! //!
//! ```no_run //! ```no_run
//! use axum::extract::FromRequestParts; //! 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`. //! 0. Implement your own extractor `T` and rejection type `R`.
//! 1. Implement `Validate` for your extractor type `T`. //! 1. Implement `Validate` for your extractor type `T`.
//! 2. In your handler function, use `Valid<WithRejection<T, R>>` as some parameter's type. //! 2. In your handler function, use `Valid<WithRejection<T, R>>` as some parameter's type.
//! //!
//! ### Example //! #### Example
//! //!
//! ```no_run //! ```no_run
//! use axum::extract::FromRequestParts; //! 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`. //! 0. Implement your own extractor `T` and rejection type `R`.
//! 1. Implement `Validate` and `HasValidate` for your extractor type `T`. //! 1. Implement `Validate` and `HasValidate` for your extractor type `T`.
//! 2. Implement `From<ValidRejection<T::Rejection>>` for `R`. //! 2. Implement `From<ValidRejection<T::Rejection>>` for `R`.
//! 3. In your handler function, use `WithRejection<Valid<T>, R>` as some parameter's type. //! 3. In your handler function, use `WithRejection<Valid<T>, R>` as some parameter's type.
//! //!
//! ### Example //! #### Example
//! //!
//! ```no_run //! ```no_run
//! use axum::extract::FromRequestParts; //! use axum::extract::FromRequestParts;

View File

@@ -38,7 +38,17 @@ pub const VALIDATION_ERROR_STATUS: StatusCode = StatusCode::UNPROCESSABLE_ENTITY
#[cfg(not(feature = "422"))] #[cfg(not(feature = "422"))]
pub const VALIDATION_ERROR_STATUS: StatusCode = StatusCode::BAD_REQUEST; 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)] #[derive(Debug, Clone, Copy, Default)]
pub struct Valid<E>(pub E); pub struct Valid<E>(pub E);