Request Validation

Validate Express API request bodies with TypeScript type guards.

Updated Jan 24, 2026
One-click install
npx skills add https://github.com/chad3814/cawpile-video-gen --skill request-validation-chad3814
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Request Validation
Source: https://github.com/chad3814/cawpile-video-gen/tree/main/.claude/skills/spekka-global-validation
Command: npx skills add https://github.com/chad3814/cawpile-video-gen --skill request-validation-chad3814

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

TypeScript-based input validation for API requests and video data structures. Use this when validating request bodies in Express handlers, implementing type guards, or validating RenderRequest and RecapBook data. Ensures type safety at API boundaries.

Core Features & Use Cases

  • TypeScript Type Guards: Use TypeScript types and type guards for compile-time and runtime validation
  • Server-Side Validation: All API endpoints must validate request bodies against defined types
  • Fail Early: Validate input at API boundary; reject invalid requests before processing
  • Specific Error Messages: Return clear, field-specific errors: { error: 'Invalid month', field: 'month' }
  • Request Body Validation: Validate RenderRequest fields (month 1-12, year valid, books array structure)
  • Type Safety: Define interfaces in src/lib/types.ts and enforce at API boundaries
  • Business Rule Validation: Validate video constraints (frame counts, durations, book data completeness)
  • No Client-Side Validation: This is a server-to-server API; all validation happens server-side

Quick Start

Validate a sample RenderRequest payload against the defined types to verify server-side validation behavior.

Frequently Asked Questions about Request Validation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I validate Express request bodies using TypeScript type guards?

Validate Express request bodies using TypeScript type guards by applying runtime checks at API boundaries to enforce interfaces and reject invalid inputs early. This ensures strict compile-time and runtime type safety for server-side handlers before processing.

What is the best way to return specific field-level errors for invalid API requests?

Return specific field-level errors for invalid API requests by validating data structures against defined interfaces and outputting clear messages like { error: 'Invalid month', field: 'month' }. This pinpoints exact validation failures for the client.

How do I enforce strict validation for RenderRequest data in an Express handler?

Enforce strict validation for RenderRequest data in an Express handler by checking fields like month (1-12), valid years, and the books array structure. This guarantees payload completeness before the server processes the video rendering request.

Can I use TypeScript type guards for server-side video data validation?

You can use TypeScript type guards for server-side video data validation to enforce business rules like frame counts, durations, and book data completeness. This rejects invalid video constraints early at the API boundary.

Why should API validation happen at the server boundary instead of on the client side?

API validation should happen at the server boundary because this is a server-to-server API where client-side validation is bypassed. Validating input early at the Express handler ensures robust, production-grade type safety before any processing begins.

How do I validate RecapBook data structures against defined TypeScript interfaces?

Validate RecapBook data structures against defined TypeScript interfaces by using type guards to check data completeness and enforce types from src/lib/types.ts. This guarantees the RecapBook payload matches API boundary requirements before processing.