Skip to main content
Drizzle provides official plugins to generate runtime validation schemas from your Drizzle ORM schemas. These plugins automatically create validators for insert, update, and select operations, ensuring type safety at both compile time and runtime.

Available Validators

Drizzle supports four popular validation libraries:

Zod

The most popular TypeScript-first schema validation library

Valibot

Modular and lightweight validation library

TypeBox

JSON Schema Type Builder with static type inference

ArkType

TypeScript-native runtime validation with 1:1 type/validator syntax

Zod

Installation

Basic Usage

Customizing Schemas

Override Field Validation

Refine Fields

Refine fields before they become optional/nullable:

Pick Specific Fields

API Validation Example

Features

  • Create select schemas for tables, views, and enums
  • Create insert and update schemas for tables
  • Full type inference from Drizzle schemas
  • Supports all PostgreSQL, MySQL, and SQLite dialects
  • Refine and customize generated schemas

Valibot

Installation

Basic Usage

Customizing Schemas

Refining Fields

TypeBox

Installation

Basic Usage

Customizing Schemas

Refining Fields

ArkType

Installation

Basic Usage

Customizing Schemas

Refining Fields

Comparison

Common Patterns

Multi-step Form Validation

API Request/Response Validation

Partial Updates

Nested Relations Validation

Framework Integration

Next.js Server Actions

app/actions.ts

tRPC Integration

server/routers/users.ts

Hono Validation

Best Practices

1

Generate once, reuse everywhere

Create validation schemas once and export them for use across your application:
schemas/users.ts
2

Customize for specific use cases

Create specialized schemas for different operations:
3

Use safe parsing in production

Use safeParse to handle validation errors gracefully:
4

Type inference

Infer TypeScript types from your validation schemas:

Next Steps

Drizzle Seed

Generate test data that validates against your schemas

API Development

Build type-safe APIs with Drizzle and validation