What problem does it solve?
MediatorLite v2's source-generation-first validation model eliminates manual pipeline configuration, but agents and developers often introduce hard-to-debug issues by hand-registering behaviors, placing validators in unscanned assemblies, or misusing the error contract. This Skill eliminates those misconfigurations and ensures validation works as intended with zero redundant setup.
Core Features & Use Cases
- Dual-Layer Validation Guidance: Covers both built-in DataAnnotations attribute validation and custom business-rule
IValidator<T> implementations, with clear rules for when to use each.
- Error Contract & Pipeline Semantics: Teaches how to work with
ValidationResult, ValidationError, and ValidationException to surface consistent, structured validation errors at API boundaries like HTTP 400 responses.
- Anti-Pattern Prevention: Flags common v2 mistakes including duplicate
ValidationBehavior<,> registration, relying on [BehaviorOrder] to adjust validation priority, and throwing from ValidateAsync instead of returning failure results.
- Use Case Example: If you are adding input validation to a new MediatorLite
CreateOrderCommand and need to ensure both attribute checks (like [Required] on the CustomerId property) and custom business rules (like verifying the customer exists in the database) run correctly without breaking the source-generated pipeline, this Skill provides the exact steps and guardrails.
Quick Start
Use the mediatorlite-validation skill to add attribute-based and custom business rule validation to your new MediatorLite order creation request, and configure your API to return structured 400 error responses for any invalid input.