What problem does it solve?
Guides design of request/response DTOs, field-level and cross-field validation, and input sanitization for Go 1.26+ APIs in a multi-tenant platform. DTOs serve two roles: HTTP request/response types for the API Gateway's external endpoints, and NATS message payloads (MsgPack-serialized) for inter-service communication. Covers go-playground/validator struct tags (required, min, max, oneof, uuid), custom cross-field validators, DTO-to-domain model mapping functions, standard MsgPack response envelope with error codes, cursor-based pagination DTOs, CloudEvents envelope (MsgPack-serialized) for NATS JetStream messages, and XSS/HTML sanitization patterns. Produces implementation-ready Go struct definitions with validation tags and mapping functions for PostgreSQL 18 backed services.
Core Features & Use Cases
- HTTP and NATS DTO definitions separated by clear mapping functions.
- Validation tags for required, min, max, oneof, uuid, plus cross-field validators.
- DTO-to-domain mapping, with tenant context and input sanitization.
- Standard envelopes: MsgPack CloudEvents for NATS, pagination DTOs, and error handling patterns.
- Security-ready input sanitization patterns (XSS prevention) for API inputs.
Quick Start
Define HTTP and NATS DTO structs, implement ToDomain mappings, and plug in validation and sanitization to produce production-ready Go types.