Zero-dependency, strictly typed Chilean RUT/RUN utilities for modern TypeScript.
Validate, format, clean, mask, and parse barcodes from Chilean national IDs β with branded types, structured errors, and i18n support.
| Package | Version | Description |
|---|---|---|
@rut-toolkit/core |
Core utilities: validation, formatting, cleaning, masking, barcode parsing, business rules, and errors. | |
@rut-toolkit/zod |
Zod v4 schemas with automatic formatting, i18n error messages, and typed custom issues. |
# Core only
pnpm add @rut-toolkit/core
# With Zod integration
pnpm add @rut-toolkit/zod @rut-toolkit/core zodimport { isRut, formatRut, toValidRut } from "@rut-toolkit/core";
if (isRut("12.345.678-5")) {
console.log(formatRut("12.345.678-5")); // "12.345.678-5"
}
const rut = toValidRut("12345678-5"); // ValidRut (branded string)import { rutSchema } from "@rut-toolkit/zod";
const rut = rutSchema.parse(" 12.345.678-5 "); // "12345678-5"rut-toolkit/
βββ packages/
β βββ core/ @rut-toolkit/core β validation, formatting, errors
β βββ zod/ @rut-toolkit/zod β Zod v4 schema adapter
β βββ config/ Shared tsconfig and tsdown presets
βββ turbo.json Turborepo task pipeline
βββ package.json Root workspace (pnpm)
- Node.js 18+ (see
enginesin the rootpackage.json). CI uses the version in.node-version. - pnpm 10+ (see
packageManagerin the rootpackage.json).
git clone https://github.com/matcastaneda/rut-toolkit.git
cd rut-toolkit
pnpm install| Command | Description |
|---|---|
pnpm dev |
Run package dev scripts via Turbo |
pnpm build |
Build all packages with tsdown (via Turbo) |
pnpm clean / pnpm clean:all |
Clean build outputs; clean:all also removes node_modules |
pnpm test |
Run Vitest for all packages (via Turbo) |
pnpm test:coverage |
Same as tests with V8 coverage (matches CI) |
pnpm typecheck |
Type-check all packages with tsc (via Turbo) |
pnpm lint |
Lint with Biome (warnings fail the run) |
pnpm lint:fix |
Lint with Biome and apply fixes |
pnpm format |
Format with Biome |
pnpm lint:packages |
Validate packages with Publint (after build) |
pnpm lint:types |
Check export types with ATTW (after build) |
pnpm lint:dependencies |
Detect unused deps with Knip |
pnpm lint:spell |
Spell check with CSpell |
pnpm size |
Run size-limit per package (after build) |
pnpm size:json |
Write per-package .size-report.json (used in CI) |
Run tasks for a specific package:
pnpm test --filter=@rut-toolkit/core
pnpm build --filter=@rut-toolkit/zodFull API docs: rut-toolkit.dev
- Fork the repository
- Create a feature branch (
git checkout -b feat/my-feature) - Make your changes and add tests
- Run
pnpm test,pnpm lint, andpnpm typecheck(usepnpm test:coveragebefore opening a PR) to verify - Commit with a descriptive message
- Open a Pull Request
Tip
See CONTRIBUTING.md for more details.
This project uses Changesets for versioning. If your change affects the public API, run pnpm changeset and follow the prompts.
MIT Β© MatΓas CastaΓ±eda