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

@denisetiya/valdix

v1.0.1

Published

Zero-dependency high-performance schema validation with multilingual errors.

Readme

@denisetiya/valdix

@denisetiya/valdix is a TypeScript schema validation library inspired by Zod, with additional features for backend and frontend integration:

  • zero runtime dependencies
  • high performance
  • simple API surface
  • multi-language error messages
  • structured error contracts for APIs and forms

Why @denisetiya/valdix

  • Lightweight: no external runtime dependencies.
  • Fast: synchronous parser with minimal allocations.
  • Practical: parse / safeParse plus chainable schema APIs.
  • Internationalized: built-in id and en locales, plus custom locale registration.
  • Modular: source code is organized into core, schemas, and factories.

Installation

pnpm add @denisetiya/valdix

Quick Start

import { v } from "@denisetiya/valdix";

const UserSchema = v.object({
  id: v.number().int().positive(),
  name: v.string().min(2),
  email: v.string().email(),
  role: v.enum(["admin", "user"]).default("user"),
  bio: v.string().max(160).optional()
});

const result = UserSchema.safeParse({
  id: 1,
  name: "Deni",
  email: "[email protected]"
});

if (!result.success) {
  console.log(result.error.toResponse());
} else {
  console.log(result.data);
}

Core API

  • parse(input, options?): throws ValdixError when invalid.
  • safeParse(input, options?): returns { success, data | error }.
  • parseAsync(input, options?), safeParseAsync(input, options?): async parsing flow.
  • optional(), nullable(), nullish(), default(value), catch(value).
  • refine(check, message?), refineAsync(check, message?).
  • superRefine((value, ctx) => ctx.addIssue(...)), superRefineAsync(...).
  • transform(fn), pipe(schema).
  • array(), or(schema), and(schema).
  • metadata({...}), brand("BrandName").

Schema Factories

  • v.string()
  • v.number()
  • v.bigint()
  • v.boolean()
  • v.date()
  • v.literal(value)
  • v.enum([...])
  • v.null()
  • v.undefined()
  • v.instanceOf(MyClass)
  • v.object(shape)
  • v.strictObject(shape)
  • v.array(itemSchema)
  • v.tuple([schema1, schema2])
  • v.record(valueSchema)
  • v.strictRecord(keySchema, valueSchema)
  • v.set(itemSchema)
  • v.map(keySchema, valueSchema)
  • v.union([schema1, schema2])
  • v.intersection(schemaA, schemaB)
  • v.discriminatedUnion("type", { ... })
  • v.preprocess(fn, schema)
  • v.coerce.string(), v.coerce.number(), v.coerce.bigint(), v.coerce.boolean(), v.coerce.date()

Feature Highlights

  • Path-first error API: find(path), findAll(path), contains(path).
  • Structured summary output: summary() returns JSON objects (field, label, code, message).
  • API-ready error output: toResponse().
  • RFC7807 output: toProblemDetails().
  • Error utilities: findIssue, findIssues, containsIssue, buildErrorResponse, buildProblemDetails.
  • Object utilities: partial(), deepPartial(), required(keys?), deepRequired(), omit(), merge(), keyof().
  • Collection utility: array().unique(selector?).
  • String utilities: slug(), cuid(), uuid(), datetime().
  • Schema export: toJSONSchema(schema), toOpenAPISchema(schema).
  • React helper subpath: @denisetiya/valdix/react.

Multi-language Errors

Built-in locales

  • id (default)
  • en

Set global locale

import { v } from "@denisetiya/valdix";

v.setLocale("en");
// or v.configure({ locale: "en" });

Override locale per parse

const schema = v.string().email();
const result = schema.safeParse("invalid-email", { locale: "en" });

Register a custom locale

import { v } from "@denisetiya/valdix";

v.registerLocale("jv", {
  custom: "Invalid input (custom locale).",
  invalid_type: "Invalid value type."
});

Custom error map

import { v } from "@denisetiya/valdix";

v.configure({
  errorMap: (issue, ctx) => `[${issue.code}] ${ctx.defaultMessage}`
});

Error Handling

import { ValdixError, v } from "@denisetiya/valdix";

try {
  v.strictObject({
    profile: v.object({
      email: v.string().email()
    })
  }).parse({
    profile: {
      email: "invalid-email"
    }
  });
} catch (error) {
  if (error instanceof ValdixError) {
    console.log(error.find("profile.email"));
    console.log(error.findAll("profile.email"));
    console.log(error.contains("profile.email"));

    console.log(error.summary());
    // [{ field, label, code, message }]

    console.log(error.summary({
      labels: { "profile.email": "User Email" }
    }));

    console.log(error.toResponse({
      message: "Validation failed"
    }));

    console.log(error.toProblemDetails({
      title: "Payload validation failed",
      instance: "/api/users"
    }));
  }
}

flatten() is still available for compatibility, but toResponse() is recommended.

Schema Export

import { toJSONSchema, toOpenAPISchema, v } from "@denisetiya/valdix";

const UserSchema = v.object({
  id: v.string().uuid().brand("UserId"),
  email: v.string().email()
}).metadata({
  title: "UserPayload",
  description: "Schema for user payload"
});

const jsonSchema = toJSONSchema(UserSchema);
const openApiSchema = toOpenAPISchema(UserSchema);

React Helper

Use @denisetiya/valdix/react for form-oriented error mapping:

import { toFormErrorState } from "@denisetiya/valdix/react";

const state = toFormErrorState(result.error, {
  email: true
});

Real-World Pattern Examples

const SlugSchema = v
  .string()
  .trim()
  .toLowerCase()
  .pipe(v.string().regex(/^[a-z0-9-]+$/));

const slug = SlugSchema.parse("  HELLO-WORLD  ");
// "hello-world"
const EventSchema = v.discriminatedUnion("type", {
  user: v.object({
    type: v.literal("user"),
    username: v.string().min(3)
  }),
  system: v.object({
    type: v.literal("system"),
    level: v.number().int()
  })
});

Development

pnpm install
pnpm run typecheck
pnpm run lint
pnpm run test
pnpm run build
pnpm run bench

Wiki Documentation

Detailed docs are available in:

Benchmark

A basic benchmark is available at benchmarks/basic.bench.mjs.

pnpm run bench

License

MIT