Crates.io | axum_serde_valid |
lib.rs | axum_serde_valid |
version | 0.23.1 |
source | src |
created_at | 2022-11-03 06:10:00.998945 |
updated_at | 2024-06-14 14:21:36.412023 |
description | Axum extractor sets of JSON validation. |
homepage | |
repository | https://github.com/yassun7010/axum_serde_valid.git |
max_upload_size | |
id | 704065 |
size | 13,503 |
This crate is a Rust library for providing validation mechanism to axum with serde_valid crate.
More information about this crate can be found in the crate documentation.
This crate works with Cargo and can be found on crates.io with a Cargo.toml like:
[dependencies]
axum = "0.6"
axum_serde_valid = "0.23.1"
serde = "^1.0"
serde_valid = "0.20"
use axum::{routing::post, Router};
use axum_serde_valid::Json;
use serde::Deserialize;
use serde_valid::Validate;
#[derive(Deserialize, Validate)]
struct User {
#[validate(max_length = 3)]
name: String,
}
let app = Router::<()>::new().route("/json", post(|user: Json<User>| async move { "hello" }));
License: MIT