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

zod-prime

v1.0.1

Published

Enhance Zod with real-world schema utilities for production-grade apps.

Readme

// File: README.md

zod-prime

zod-prime supercharges your Zod schemas with deep partial/required, recursive omit/pick, error flattening, cross-field validation, JSON Schema conversion, and more. All utilities are fully type-safe and ready for production.

✨ Features

  • deepPartial – Make any Zod schema deeply optional (all fields optional, recursively)
  • deepRequired – Make any Zod schema deeply required (all fields required, recursively)
  • deepOmit – Deeply omit keys from any Zod schema (type-safe, recursive)
  • deepPick – Deeply pick only certain keys from any Zod schema (type-safe, recursive)
  • mergeSchemas – Deeply merge two Zod object schemas
  • zodToJsonSchema – Convert a Zod schema to JSON Schema (for OpenAPI, docs, etc)
  • zodInferType – Infer TypeScript type from a Zod schema (for DX)
  • zodDefault – Set a default value for any Zod schema, even deeply
  • emailPasswordSchema – Flexible, secure email-password schema generator
  • flattenErrors – Simplify Zod errors into readable form (for UI, logs, etc)
  • refineObject – Add cross-field validation to Zod objects (e.g. password confirmation)
  • smartEnum – Create safe enums from string arrays (type-safe, autocompletion)

📦 Installation

npm install zod-prime zod

Peer dependency: You must have zod installed in your project.

🚀 Quick Start

import {
  deepPartial,
  deepRequired,
  deepOmit,
  deepPick,
  mergeSchemas,
  zodToJsonSchema,
  zodInferType,
  zodDefault,
  emailPasswordSchema,
  flattenErrors,
  refineObject,
  smartEnum,
} from 'zod-prime';
import { z } from 'zod';

// Example: Deep Partial
const schema = z.object({ user: z.object({ name: z.string(), age: z.number() }) });
const partial = deepPartial(schema);
// All fields are now optional, deeply

// Example: Deep Omit
const omitted = deepOmit(schema, ['age']);

// Example: Merge Schemas
const merged = mergeSchemas(z.object({ foo: z.string() }), z.object({ bar: z.number() }));

// Example: Smart Enum
const Color = smartEnum(['red', 'green', 'blue'] as const);

// Example: Email/Password Schema
const loginSchema = emailPasswordSchema({ minPasswordLength: 10, requireSpecialChar: true });

// Example: Flatten Zod Errors
// flattenErrors(zodError) => [{ path, message }]

🧠 Usage & API

Deep Partial

import { deepPartial } from 'zod-prime';
import { z } from 'zod';
const schema = z.object({ user: z.object({ name: z.string(), age: z.number() }) });
const partial = deepPartial(schema);
// All fields are now optional, deeply

Deep Required

import { deepRequired } from 'zod-prime';
// Makes all fields required, deeply

Deep Omit

import { deepOmit } from 'zod-prime';
const schema = z.object({ a: z.string(), b: z.object({ c: z.number(), d: z.string() }) });
const omitted = deepOmit(schema, ['b']);
// Removes 'b' everywhere in the schema

Deep Pick

import { deepPick } from 'zod-prime';
const schema = z.object({ a: z.string(), b: z.object({ c: z.number(), d: z.string() }) });
const picked = deepPick(schema, ['a', 'c']);
// Keeps only 'a' and 'c' everywhere in the schema

Merge Schemas

import { mergeSchemas } from 'zod-prime';
const a = z.object({ foo: z.string() });
const b = z.object({ bar: z.number() });
const merged = mergeSchemas(a, b);
// merged: { foo: string, bar: number }

Zod to JSON Schema

import { zodToJsonSchema } from 'zod-prime';
const schema = z.object({ foo: z.string() });
const jsonSchema = zodToJsonSchema(schema);
// { type: 'object', properties: { foo: { type: 'string' } } }

zodInferType

import { z } from 'zod';
import type { zodInferType } from 'zod-prime';
const schema = z.object({ foo: z.string() });
type T = zodInferType<typeof schema>; // { foo: string }

zodDefault

import { zodDefault } from 'zod-prime';
const schema = zodDefault(z.string(), 'hello');
schema.parse(undefined); // 'hello'

Deep Required

import { deepRequired } from 'zod-prime';
// Makes all fields required, deeply

Email Password Schema

import { emailPasswordSchema } from 'zod-prime';

const schema = emailPasswordSchema({ minPasswordLength: 10, requireSpecialChar: true });

Flatten Errors

import { flattenErrors } from 'zod-prime';
// Converts ZodError to array of { path, message }

Refine Object

import { refineObject } from 'zod-prime';

const schema = refineObject(
  z.object({ password: z.string(), confirm: z.string() }),
  (data) => data.password === data.confirm,
  'Passwords must match'
);

Smart Enum

import { smartEnum } from 'zod-prime';

const Color = smartEnum(['red', 'green', 'blue'] as const);

🧪 Testing & Development

npm run test

🔧 Build & Type Checking

npm run build

🧹 Lint & Format

npm run lint

🤝 Contributing

Contributions, issues, and feature requests are welcome! Please open an issue or PR on GitHub.

📄 License

MIT