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

@zudojs/schema

v1.0.0

Published

Type-safe schema definition, parsing, and validation engine for data contracts.

Readme

@zudojs/schema

Type-safe schema definition, parsing, and validation engine for data contracts.

Installation

npm install @zudojs/schema

Quick Start

import { schema, type Infer } from "@zudojs/schema";

const UserSchema = schema.object({
  id: schema.string().uuid(),
  email: schema.string().email(),
  age: schema.number().int().positive(),
});

type User = Infer<typeof UserSchema>;

Parsing untrusted input

parse and safeParse both accept unknown — validating a value that is not yet known to match the schema is the point of the boundary:

const fromTheWire: unknown = await request.json();

// Throws SchemaError, carrying `issues`, if the value does not match.
const user = UserSchema.parse(fromTheWire);

// Or handle failure without exceptions.
const result = UserSchema.safeParse(fromTheWire);

if (result.success) {
  result.data.email;
} else {
  result.issues;
}

The two entry points always agree: any value safeParse reports as invalid causes parse to throw, rather than being returned as a partial result. Infer<T> gives a schema's output type and SchemaInput<T> its declared input type, which is unaffected by parse accepting unknown.

Limits and untrusted input

Parsing is bounded, so a hostile payload cannot exhaust the stack or the CPU:

UserSchema.safeParse(fromTheWire, { maxDepth: 32, maxIssues: 20 });

maxDepth (default 100) is enforced by every composite schema, and a circular structure is reported as a circular_reference issue rather than recursing forever. Strings default to a 255-character ceiling and arrays to 1000 items before any pattern or item schema runs — raise either with .max().

A .refine() or .transform() callback that throws is reported as a refine_failed / transform_failed issue carrying the original message. Anything else thrown during parsing — a genuine defect — propagates out of safeParse instead of being flattened into "invalid input".

Coercion

For query parameters and form data, where everything arrives as a string:

const Query = schema.object({
  page: schema.coerce.number().int().min(1).default(1),
  verbose: schema.coerce.boolean().default(false),
});

Stricter than the JavaScript built-ins it wraps: "" and " " are rejected rather than becoming 0, "1e999" is rejected rather than becoming Infinity, and "1"/"0"/"yes"/"on" are accepted as booleans.

Features

  • Type-safe schema definitions
  • Runtime validation with detailed errors
  • Schema composition: object, union, discriminated union, intersection, lazy
  • Transformations, refinements and defaults
  • Explicit coercion for string-typed input
  • Depth, cycle, length and issue-count limits
  • Prototype-pollution protection on object and record keys

Use Cases

  • API request/response validation
  • Configuration validation
  • Form data validation
  • Data contract enforcement