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

@rut-toolkit/zod

v0.1.5

Published

Zod v4 schemas for Chilean RUT/RUN validation with automatic formatting, i18n error messages, and typed custom issues.

Readme

@rut-toolkit/zod

npm version bundle size license

Zod v4 schemas for Chilean RUT/RUN validation with automatic formatting, i18n error messages, and typed custom issues.

Drop-in Zod schemas powered by @rut-toolkit/core. Parse a raw string, get back a validated and formatted RUT — ready for forms, APIs, and DTOs.

✨ Features

  • Ready-to-use schemasrutSchema, rutCleanSchema, rutFormattedSchema for common output formats.
  • Validate-then-transform — modulo-11 check runs first, then the output is normalized via formatRut.
  • Typed custom issues — every Zod issue carries rutErrorCode and rutErrorMeta in issue.params.
  • i18n defaults — error messages in Spanish and English, with per-code overrides.
  • Placeholder rejection — optionally reject known fake RUTs (11.111.111-1, etc.).
  • Auto-trim — leading/trailing whitespace is stripped by default (configurable).

📦 Installation

npm install @rut-toolkit/zod @rut-toolkit/core zod
# or
pnpm add @rut-toolkit/zod @rut-toolkit/core zod
# or
yarn add @rut-toolkit/zod @rut-toolkit/core zod
# or
bun add @rut-toolkit/zod @rut-toolkit/core zod

[!IMPORTANT] Peer dependencies: zod v4 (^4.0.0) and @rut-toolkit/core (see peerDependencies in this package’s package.json for the supported range). Install them alongside @rut-toolkit/zod — they are not bundled.

🚀 Quick Start

Basic Schema

import { z } from "zod";
import { rutSchema } from "@rut-toolkit/zod";

const UserSchema = z.object({
  name: z.string().min(1),
  rut: rutSchema,
});

const data = UserSchema.parse({ name: "Ana", rut: " 12.345.678-5 " });
console.log(data.rut); // "12345678-5"

Presets

import { rutCleanSchema, rutFormattedSchema } from "@rut-toolkit/zod";

rutCleanSchema.parse("12.345.678-5");     // "123456785"    (DB/storage)
rutFormattedSchema.parse("123456785");     // "12.345.678-5" (UI/display)

Custom Schema

import { createRutSchema } from "@rut-toolkit/zod";

const strictSchema = createRutSchema({
  format: { withDots: true, withHyphen: true },
  rejectPlaceholders: true,
  locale: "en",
  messages: {
    RUT_EMPTY: "Please enter your RUT.",
    RUT_DV_MISMATCH: "The check digit is wrong.",
  },
});

strictSchema.parse("12.345.678-5"); // "12.345.678-5"

Typed Error Params

import { rutSchema } from "@rut-toolkit/zod";
import type { ZodRutIssueParams } from "@rut-toolkit/zod";

const result = rutSchema.safeParse("12345678-0");

if (!result.success) {
  const issue = result.error.issues[0] as { params?: ZodRutIssueParams };

  issue.params?.rutErrorCode; // "RUT_DV_MISMATCH"
  issue.params?.rutErrorMeta; // { category: "validation", severity: "error", httpStatus: 422 }
}

Disable Trim

import { createRutSchema } from "@rut-toolkit/zod";

const noTrimSchema = createRutSchema({ trim: false });

noTrimSchema.safeParse(" 12.345.678-5 "); // fails — whitespace is not stripped

📦 Exports

| Export | Type | Description | | :--- | :--- | :--- | | createRutSchema | Function | Factory to build customized schemas with format, locale, and message overrides. | | rutSchema | ZodSchema | Default schema — compact output: "12345678-5". | | rutCleanSchema | ZodSchema | Storage schema — raw digits only: "123456785". | | rutFormattedSchema | ZodSchema | Display schema — dotted format: "12.345.678-5". | | ZodRutSchemaOptions | Interface | Configuration for createRutSchema (format, locale, messages, trim, rejectPlaceholders). | | ZodRutIssueParams | Interface | Shape of issue.params on custom Zod issues (rutErrorCode, rutErrorMeta). |

📖 Documentation

Full API docs: rut-toolkit.dev

📝 License

MIT © Matías Castañeda