| Crates.io | domainstack-envelope |
| lib.rs | domainstack-envelope |
| version | 1.0.0 |
| created_at | 2026-01-06 13:50:54.681053+00 |
| updated_at | 2026-01-06 13:50:54.681053+00 |
| description | Error envelope integration for domainstack: convert validation errors to structured HTTP error responses |
| homepage | |
| repository | https://github.com/blackwell-systems/domainstack |
| max_upload_size | |
| id | 2025896 |
| size | 22,709 |
Convert domainstack validation errors to error-envelope HTTP error format. Part of the domainstack full-stack validation ecosystem.
Add this to your Cargo.toml:
[dependencies]
domainstack = "1.0"
domainstack-envelope = "1.0"
Convert validation errors to error-envelope format:
use domainstack::{Validate, ValidationError};
use domainstack_envelope::IntoEnvelopeError;
use error_envelope::Error;
fn create_user(user: User) -> Result<User, Error> {
user.validate()
.map_err(|e| e.into_envelope_error())?;
Ok(user)
}
Converts structured validation errors to error-envelope's standard HTTP error format:
{
"error": {
"code": "validation_failed",
"message": "Validation failed",
"details": {
"email": ["Invalid email format"],
"age": ["Must be at least 18"]
}
}
}
user.address.city map correctlyUse with framework adapters for automatic error conversion:
// Axum
use domainstack_axum::{DomainJson, ErrorResponse};
async fn handler(DomainJson(user): DomainJson<User>) -> Result<Json<User>, ErrorResponse> {
// Validation errors automatically converted to error-envelope format
Ok(Json(user))
}
// Actix-web
use domainstack_actix::{DomainJson, ErrorResponse};
async fn handler(user: DomainJson<User>) -> Result<HttpResponse, ErrorResponse> {
// Validation errors automatically converted to error-envelope format
Ok(HttpResponse::Ok().json(user.into_inner()))
}
For complete documentation, examples, and usage guides, see:
Apache 2.0