Skip to content
Back to skills

Zod

ASecurity

> TypeScript-first schema validation with static type inference.

  • 2 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added October 26, 2026
developmenttypescriptreactnextjsapi

Works with

  • api

Security analysis

A100/100

Scanned October 26, 2026

npx -y skills add nhan03bit/ultrathink --skill zod --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Zod?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Zod
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/nhan03bit-zod/badge)](https://www.skillsdirectory.com/skills/nhan03bit-zod)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
# Zod

> TypeScript-first schema validation with static type inference.

## When to Use
- Validating API request/response bodies
- Form validation with react-hook-form
- Environment variable validation
- Runtime type checking at system boundaries

## Core Patterns

### Schema Definition
```typescript
import { z } from "zod";

const UserSchema = z.object({
  name: z.string().min(1).max(100),
  email: z.string().email(),
  age: z.number().int().positive().optional(),
  role: z.enum(["admin", "user", "moderator"]),
  tags: z.array(z.string()).default([]),
});

type User = z.infer<typeof UserSchema>;
```

### Validation
```typescript
// parse() throws on failure, safeParse() returns result object
const result = UserSchema.safeParse(data);
if (!result.success) {
  console.log(result.error.flatten()); // { fieldErrors: { email: ["Invalid email"] } }
}
```

### Common Combinators
- `.transform()` — transform after validation
- `.refine()` — custom validation logic
- `.superRefine()` — multi-field validation with path
- `z.discriminatedUnion()` — tagged unions
- `z.intersection()` — combine schemas
- `.passthrough()` / `.strict()` — unknown key handling

### Integration
- **react-hook-form**: `zodResolver(schema)` in useForm
- **tRPC**: schemas as input/output validators
- **Next.js**: server action validation
- **Env vars**: `z.object({...}).parse(process.env)` at startup

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.