TypeScript

Prisma to Zod examples

Generate Zod validation starters from Prisma model definitions and enum fields.

User and posts models

Scalar fields, enum values, nullable fields, arrays, attributes, and relation warnings.

enum Role {
  USER
  ADMIN
}

model User {
  id        String   @id @default(cuid())
  email     String   @unique
  role      Role     @default(USER)
  createdAt DateTime @default(now())
  profile   Json?
  posts     Post[]
}

model Post {
  id        String   @id @default(cuid())
  title     String
  content   String?
  published Boolean  @default(false)
  author    User?    @relation(fields: [authorId], references: [id])
  authorId  String?
}
Open example

Product model

Decimal, integer, BigInt, bytes, nullable, and list fields.

model Product {
  id          String   @id @default(cuid())
  sku         String   @unique
  price       Decimal
  inventory   Int
  views       BigInt
  image       Bytes?
  tags        String[]
  metadata    Json?
}
Open example

Use these examples with guides