What problem does it solve?
Unvalidated API inputs can lead to data corruption, security vulnerabilities, and unexpected application behavior, requiring tedious manual checks. This skill automates and standardizes input validation.
Core Features & Use Cases
- Zod Schema Validation: Define robust, type-safe validation schemas for all incoming request data (body, query, params), catching errors early.
- Data Transformation: Automatically transform incoming string parameters to appropriate types (e.g., string to number, string to Date), simplifying data handling in controllers.
- Reusable Validation Logic: Create and reuse complex validation rules and schemas across multiple endpoints, ensuring consistency and reducing development time.
- Use Case: Implement validation for a new
createWealth endpoint. You'll define a Zod schema to ensure title is a string, quantity is a positive integer, and targetId is required if targetType is not 'community', preventing invalid data from entering your system.
Quick Start
Create a Zod schema to validate a new POST /api/v1/items endpoint, ensuring the name field is a non-empty string and price is a positive number.