Registry / database / drizzle-arktype

drizzle-arktype

JSON →
library0.1.3jsnpmunverified

A plugin for Drizzle ORM that auto-generates Arktype validation schemas from Drizzle table schemas, ensuring runtime validation aligns exactly with your database definitions. Version 0.1.3 is stable; release cadence is monthly. Key differentiator: eliminates manual duplication of validation logic when using Arktype with Drizzle, supporting PostgreSQL, MySQL, SQLite. Requires arktype >=2.0.0 and drizzle-orm >=0.36.0. Ships TypeScript types.

npm install drizzle-arktype
INSTALL
IMPORT
SIG · DRIZZLE-ARKTYPE
D
drizzle-arktype
databasejavascriptv0.1.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

drizzleArk
✓ import { drizzleArk } from 'drizzle-arktype'
✗ const drizzleArk = require('drizzle-arktype')
ESM-only package; CommonJS require is not supported.
type ArkSchema
✓ import type { ArkSchema } from 'drizzle-arktype'
Use type import for TypeScript to avoid runtime inclusion.
inferInsertSchema and inferSelectSchema
✓ import { inferInsertSchema, inferSelectSchema } from 'drizzle-arktype'
✗ import { inferSchema } from 'drizzle-arktype'
Two separate inference functions; there is no unified inferSchema export.

Creates Arktype schemas from a Drizzle table definition and validates data.

import { pgTable, integer, text } from 'drizzle-orm/pg-core'; import { drizzleArk } from 'drizzle-arktype'; const users = pgTable('users', { id: integer().primaryKey(), name: text().notNull(), }); const { schema, insertSchema, selectSchema } = drizzleArk(users); // schema: Ark type for full row // insertSchema: Ark type for insert (without auto-generated fields) // selectSchema: Ark type for select results import { type } from 'arktype'; const parsed = schema({ id: 1, name: 'Alice' }); console.log(parsed); // { id: 1, name: 'Alice' } const invalid = schema({ id: '1', name: 'Bob' }); console.log(invalid.problems); // validation errors
Debug
Known issues
gotchadrizzleArk() only accepts a single table definition, not an array or object of tables.
fix
Call drizzleArk() separately for each table.
affects: >=0.1.0
gotchaAuto-generated fields (like serial or default values) are not included in insertSchema; they must be omitted in inserts.
fix
Use insertSchema for insert operations; do not provide generated fields.
affects: >=0.1.0
deprecatedThe 'type' export from arktype is the preferred way to define schemas; older methods using 'Ark' may conflict.
fix
Use import { type } from 'arktype' instead of legacy imports.
affects: >=0.1.0
breakingVersion 0.0.x had a different API using createDrizzleArk(); renamed to drizzleArk in 0.1.0.
fix
Replace createDrizzleArk() with drizzleArk().
affects: <0.1.0
Errors
Common errors & fixes
Cannot find module 'drizzle-arktype' or its corresponding type declarations.
Missing install or incompatible versions of peer dependencies.
fix
Ensure drizzle-orm >=0.36.0 and arktype >=2.0.0 are installed: npm install drizzle-arktype arktype drizzle-orm
TypeError: drizzleArk is not a function
Using CommonJS require instead of ESM import.
fix
Change require() to import { drizzleArk } from 'drizzle-arktype'. If using CommonJS, use dynamic import: const { drizzleArk } = await import('drizzle-arktype').
Property 'problems' does not exist on type 'string | { ... }'.
Arktype returns a string on validation error, but code assumes an object with problems.
fix
Check if result is a string: if (typeof parsed === 'string') { console.log('Error:', parsed); } else { console.log(parsed); }
Upgrade
Version history
0.1.3latest on npm
Audit
Dependencies
arktyperequiredPeer dependency for defining and using Arktype schemas.
drizzle-ormrequiredPeer dependency for Drizzle ORM schema definitions.
Agent activity
9 hits · last 30 days
node
8
Resources
drizzle-arktype — npm install drizzle-arktype · libregistry