Converts Orchid ORM column schema definitions into Zod validation schemas, enabling reuse of column types for runtime validation. Current version is 1.0.88, actively maintained with releases following Orchid ORM updates. Key differentiator: automatically generates Zod schemas that match database column types (text, integer, boolean, timestamps, enums, etc.) without manual duplication. Supports TypeScript, integrates with Orchid ORM's table definitions, and handles nested validation methods like .nullable(), .default(), and .unique(). Alternative to manually writing Zod schemas aligned with database schema.
npm install orchid-orm-schema-to-zodNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Creates a Zod schema from an Orchid ORM table definition, then validates an object.
When passing a column reference (table.user.name), expect a single Zod type, not an object.
Use Zod's .transform() or .pipe() to coerce strings to dates: schemaToZod(table).transform((val) => ({ ...val, createdAt: new Date(val.createdAt) }))Define Zod schemas for relations separately or use Orchid ORM's query methods for validation.
These methods are ignored during conversion; do not rely on them for validation.
Use import { schemaToZod } from 'orchid-orm-schema-to-zod'Ensure the value matches the column type: text expects string, integer expects number, boolean expects boolean.
Pass a table object or column reference as the argument: schemaToZod(table) or schemaToZod(table.name)
Run npm install orchid-orm-schema-to-zod (and ensure zod and orchid-orm are installed)