What problem does it solve?
Unvalidated or improperly validated user input can lead to security vulnerabilities, data corruption, and application crashes, undermining trust and stability. This Skill enforces robust server-side validation to protect your application and data.
Core Features & Use Cases
- DTO Validation: Apply
class-validator decorators for declarative and type-safe input validation on Data Transfer Objects (DTOs).
- Business Rule Validation: Implement dedicated validator service classes for complex existence, uniqueness, and cross-field business rule checks.
- Fail-Fast Approach: Integrate validation at the earliest possible stage (e.g., at the start of use cases) to prevent unnecessary processing and provide immediate feedback.
- Use Case: When a user submits a form to create an article, this Skill ensures the title is not empty, within length limits, and unique before any database operations are attempted, preventing invalid data from reaching the persistence layer.
Quick Start
Help me add validation decorators to a CreateUserDto to ensure the email field is a valid email format and the password meets minimum length requirements, using class-validator.