← ClaudeAtlas

type-safety-validationlisted

Achieve end-to-end type safety with Zod runtime validation, tRPC type-safe APIs, Prisma ORM, and TypeScript 5.7+ features. Build fully type-safe applications from database to UI for 2025+ development.
aiskillstore/marketplace · ★ 329 · API & Backend · score 85
Install: claude install-skill aiskillstore/marketplace
# Type Safety & Validation ## Overview End-to-end type safety ensures bugs are caught at compile time, not runtime. This skill covers Zod for runtime validation, tRPC for type-safe APIs, Prisma for type-safe database access, and modern TypeScript features. **When to use this skill:** - Building type-safe APIs (REST, RPC, GraphQL) - Validating user input and external data - Ensuring database queries are type-safe - Creating end-to-end typed full-stack applications - Migrating from JavaScript to TypeScript - Implementing strict validation rules ## Core Stack ### 1. Zod - Runtime Validation ```typescript import { z } from 'zod' // Define schema const UserSchema = z.object({ id: z.string().uuid(), email: z.string().email(), age: z.number().int().positive().max(120), role: z.enum(['admin', 'user', 'guest']), metadata: z.record(z.string()).optional(), createdAt: z.date().default(() => new Date()) }) // Infer TypeScript type from schema type User = z.infer<typeof UserSchema> // Validate data const result = UserSchema.safeParse(data) if (result.success) { const user: User = result.data } else { console.error(result.error.issues) } // Transform data const EmailSchema = z.string().email().transform(email => email.toLowerCase()) ``` **Advanced Patterns**: ```typescript // Refinements const PasswordSchema = z.string() .min(8) .refine((pass) => /[A-Z]/.test(pass), 'Must contain uppercase') .refine((pass) => /[0-9]/.test(pass), 'Must contain number') // Di