#json-schema #axum #serde #validation

axum_serde_valid

Axum extractor sets of JSON validation

29 releases (2 stable)

1.1.0 Jan 6, 2025
1.0.0 Dec 27, 2024
0.23.1 Jun 14, 2024
0.19.0 Mar 2, 2024
0.12.0-beta.10 Nov 3, 2022

#2923 in Encoding

Download history 36/week @ 2026-02-19 12/week @ 2026-02-26 15/week @ 2026-03-05 3/week @ 2026-03-12 32/week @ 2026-03-19 3/week @ 2026-03-26 20/week @ 2026-04-02 19/week @ 2026-04-09 6/week @ 2026-04-16 5/week @ 2026-04-23 1/week @ 2026-04-30 7/week @ 2026-05-28 65/week @ 2026-06-04

72 downloads per month

MIT license

12KB
164 lines

axum_serde_valid

Latest Version Documentation GitHub license

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.

Installation

This crate works with Cargo and can be found on crates.io with a Cargo.toml like:

[dependencies]
axum = "^0.8"
axum_serde_valid = "^1.1"
serde = "^1.0"
serde_valid = "^1.0"

Example

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

Dependencies

~12–18MB
~237K SLoC