global-validation

TheophilusChinomona's avatarfrom TheophilusChinomona

Implement comprehensive validation using Zod schemas for type-safe validation on both client and server, with server-side validation as the security boundary (never trust client input). Use this skill when validating user inputs, creating API endpoints that accept data, implementing forms, defining data schemas, validating file uploads, creating validation middleware, implementing Firestore security rules or Supabase RLS, or writing validation rules for any user-provided data. Apply when working on API route handlers, form components with React Hook Form, validation middleware, Zod schema definitions (schemas/*.ts, validation/*.ts), Firestore security rules (firestore.rules), Supabase RLS policies, or any code that accepts external input. This skill ensures server-side validation always (client-side is for UX only), Zod for schema validation with TypeScript type inference (z.infer<typeof schema>), validation middleware factory for Express/Bun APIs, React Hook Form + zodResolver for forms, user-friendly error

⭐0stars🔀0forks📁View on GitHub🕐Updated Dec 30, 2025⬇️1downloads

When & Why to Use This Skill

This Claude skill facilitates the implementation of a robust, full-stack validation architecture using Zod schemas. It prioritizes security by establishing the server as the ultimate validation boundary while leveraging TypeScript's type inference to ensure end-to-end type safety. By integrating with modern frameworks like React Hook Form and backend engines like Express or Hono, it helps developers build resilient applications that prevent malformed data entry, XSS attacks, and unauthorized database access.

Use Cases

  • Case 1: Developing secure API endpoints with Zod-based validation middleware to enforce strict request body and parameter schemas.
  • Case 2: Synchronizing frontend and backend validation logic using shared Zod schemas to provide consistent UX and reliable server-side security.
  • Case 3: Implementing type-safe forms with React Hook Form and zodResolver for real-time error handling and seamless data transformation.
  • Case 4: Hardening database security by translating validation logic into Firestore security rules or Supabase Row Level Security (RLS) policies.
  • Case 5: Protecting applications from runtime failures by validating environment variables and sanitizing user-generated HTML content with DOMPurify.
nameGlobal Validation
descriptionImplement comprehensive validation using Zod schemas for type-safe validation on both client and server, with server-side validation as the security boundary (never trust client input). Use this skill when validating user inputs, creating API endpoints that accept data, implementing forms, defining data schemas, validating file uploads, creating validation middleware, implementing Firestore security rules or Supabase RLS, or writing validation rules for any user-provided data. Apply when working on API route handlers, form components with React Hook Form, validation middleware, Zod schema definitions (schemas/*.ts, validation/*.ts), Firestore security rules (firestore.rules), Supabase RLS policies, or any code that accepts external input. This skill ensures server-side validation always (client-side is for UX only), Zod for schema validation with TypeScript type inference (z.infer<typeof schema>), validation middleware factory for Express/Bun APIs, React Hook Form + zodResolver for forms, user-friendly error messages (not technical jargon), input sanitization with DOMPurify for HTML content, file upload validation (type whitelist, size limits with multer), Firestore security rules with data type and length validation, FluentValidation for .NET APIs, database-level constraints enforcement, fail-early validation principles, and environment variable validation with Zod on application startup.

Global Validation

When to use this skill:

  • When creating API endpoints that accept request bodies
  • When implementing validation middleware factory for Express/Bun/Hono
  • When defining Zod schemas for data validation with type inference
  • When creating forms with React Hook Form and zodResolver
  • When validating file uploads (MIME type whitelist, size limits with multer)
  • When writing Firestore security rules (firestore.rules) for database validation
  • When writing Supabase Row Level Security (RLS) policies
  • When implementing input sanitization with DOMPurify to prevent XSS
  • When adding validation to service layer methods (fail-early)
  • When creating custom Zod refinements (e.g., password complexity) or transforms (e.g., string to Date)
  • When writing user-friendly validation error messages (not technical jargon)
  • When validating environment variables with Zod on application startup
  • When working on any code that accepts user input or external data
  • When implementing FluentValidation for .NET API validation
  • When creating complex nested schemas with arrays and optional fields

This Skill provides Claude Code with specific guidance on how to adhere to coding standards as they relate to how it should handle global validation.

Instructions

For details, refer to the information provided in this file: global validation