| Crates.io | rustapi-validate |
| lib.rs | rustapi-validate |
| version | 0.1.207 |
| created_at | 2025-12-30 14:49:33.074461+00 |
| updated_at | 2026-01-26 00:01:58.175794+00 |
| description | Type-safe request validation for RustAPI. Wrapper around the `validator` crate with deep framework integration. |
| homepage | https://github.com/Tuntii/RustAPI |
| repository | https://github.com/Tuntii/RustAPI |
| max_upload_size | |
| id | 2012757 |
| size | 246,998 |
Declarative, type-safe request validation.
This crate integrates the validator library deeply into the RustAPI extractor system.
Manually checking if email.contains("@") in every handler is tedious and error-prone.
Define rules on your structs. RustAPI automatically runs them and returns 422 Unprocessable Entity if constraints are violated.
use rustapi_rs::prelude::*;
#[derive(Deserialize, Validate, Schema)]
pub struct UserSignup {
#[validate(email(message = "Invalid email address"))]
pub email: String,
#[validate(length(min = 8, message = "Password too short"))]
pub password: String,
#[validate(range(min = 18, max = 100))]
pub age: u8,
}
// If execution enters this function, `body` is GUARANTEED to be valid.
#[post("/signup")]
async fn signup(Json(body): Json<UserSignup>) -> impl Responder {
// ...
}
emailurllengthrangecustom (use your own functions)custom_async (async custom functions)containsregex