npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

prisma-valibot-generator

v1.2.0

Published

Prisma generator to emit Valibot schemas from your Prisma schema

Readme

Highlights

  • 🚀 Generate Valibot schemas from your Prisma models automatically
  • 📦 Per-model exports:
    • {Model}Schema (all fields required)
    • Create{Model}Schema (required scalars only)
    • Update{Model}Schema (all fields optional)
  • 🎯 Advanced enum support: Dedicated enums.ts with v.picklist() + value exports
  • 🧹 Clean schemas: Relations automatically excluded for focused validation
  • 🔧 Full type coverage: String/Int/Float/Boolean/DateTime/Json/Decimal/BigInt/Bytes/Arrays
  • ⚙️ Configurable: enumValue option supports @map for custom enum values
  • 🛡️ Type-safe: Runtime validation with comprehensive error handling
  • 📏 Lightweight: Tree-shakeable exports, minimal runtime overhead

Prerequisites

  • Node.js 18+
  • Prisma 6.12+
  • valibot

Quick start

  1. Star this repo 🌟

  2. Install

npm i -D prisma-valibot-generator
# pnpm: pnpm add -D prisma-valibot-generator
# yarn: yarn add -D prisma-valibot-generator
# bun:  bun add -d prisma-valibot-generator
  1. Add a generator block to your schema.prisma
generator valibot {
  provider  = "prisma-valibot-generator"
  output    = "./src/generated/valibot" // optional
  enumValue = "name" // optional: "name" (default) | "dbName" (for @map support)
}
  1. Generate
npx prisma generate
  1. Import and use
import * as v from 'valibot';
import { 
  UserSchema, 
  CreateUserSchema, 
  UpdateUserSchema, 
  RoleEnum,
  RoleValues 
} from './src/generated/valibot';

// Validate complete model data
const user = v.parse(UserSchema, {
  id: 1,
  email: '[email protected]',
  name: 'John Doe',
  role: 'ADMIN'
});

// Validate creation data (only required fields)
const newUser = v.parse(CreateUserSchema, { 
  email: '[email protected]',
  password: 'secret123'
});

// Validate updates (all fields optional)
const userUpdate = v.parse(UpdateUserSchema, { 
  name: 'Jane Smith' 
});

// Validate enums
const role = v.parse(RoleEnum, 'USER');

// Access enum values for UI components
console.log(RoleValues); // ['USER', 'ADMIN']

Features

🎯 Enum Support

enum Role {
  USER
  ADMIN     @map("administrator")
  MODERATOR @map("mod")
}

generator valibot {
  provider  = "prisma-valibot-generator"
  enumValue = "dbName" // Use @map values
}
import { RoleEnum, RoleValues } from './generated/valibot';

// Generated enum values respect @map
console.log(RoleValues); // ['USER', 'administrator', 'mod']

// Validation works with mapped values
v.parse(RoleEnum, 'administrator'); // ✅ Valid
v.parse(RoleEnum, 'ADMIN');         // ❌ Invalid

🧹 Relation Handling

Relations are automatically excluded from generated schemas for clean validation:

model User {
  id    Int    @id
  email String
  posts Post[] // Excluded from schemas
}

model Post {
  id       Int  @id
  title    String
  author   User @relation(fields: [authorId], references: [id]) // Excluded
  authorId Int  // Included - it's a scalar field
}

🔧 Array Support

Arrays are fully supported with proper validation:

model User {
  id       Int      @id
  tags     String[]
  scores   Int[]
}
const user = v.parse(UserSchema, {
  id: 1,
  tags: ['developer', 'typescript'],
  scores: [95, 87, 92]
});

⚙️ Configuration Options

| Option | Values | Default | Description | |--------|--------|---------|-------------| | output | string | "./generated" | Output directory for generated files | | enumValue | "name" | "dbName" | "name" | Whether to use enum names or @map values |

Error Handling

The generator provides clear, actionable error messages:

# Invalid enum configuration
❌ Invalid enumValue config: 'invalid'. Must be 'name' or 'dbName'.

# Missing enum definition  
❌ Enum 'Status' not found in schema. Available enums: Role, Priority

# Empty enum
❌ Enum 'Status' has no values. Enums must have at least one value.

Sponsor ❤️

If this saves you time or prevents bugs, please consider sponsoring to support maintenance and new features.

→ https://github.com/sponsors/omar-dulaimi

Contributing

PRs welcome. Keep diffs focused and discuss larger changes in an issue first. See the test suites for expected behavior and coverage.

License

MIT © Omar Dulaimi