Skip to main content
Home

Built and signed on GitHub Actions

Works with
This package works with Cloudflare Workers, Node.js, Deno, Bun, Browsers
This package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
This package works with Bun
This package works with Browsers
JSR Score94%
Published11 months ago (0.1.1)

TypeScript library for validating, formatting, and generating CUITs (Argentine tax identification codes) with ease and accuracy.

@brielov/cuit

A lightweight TypeScript library for validating, formatting, and generating CUITs (Código Único de Identificación Tributaria) used in Argentina. This package helps ensure CUITs are valid and properly formatted.

Installation

deno add jsr:@brielov/cuit
npx jsr add @brielov/cuit
yarn dlx jsr add @brielov/cuit
pnpm dlx jsr add @brielov/cuit
bunx jsr add @brielov/cuit

Usage

Validate and Sanitize a CUIT

The validateCuit function checks if a given CUIT is valid and returns a sanitized CUIT if valid, or null if invalid.

import { validateCuit } from "@brielov/cuit";

const validCuit = validateCuit("20-12345678-3"); // "20123456783"
const invalidCuit = validateCuit("invalid-cuit"); // null

Format a CUIT

The formatCuit function formats a sanitized CUIT with a custom separator (default is -).

import { formatCuit } from "@brielov/cuit";

const formattedCuit = formatCuit("20123456783", "/"); // "20/12345678/3"

Guess a CUIT from DNI

The guessCuit function attempts to guess a CUIT based on a DNI and gender. It returns a formatted CUIT string.

import { Gender, guessCuit } from "@brielov/cuit";

const guessedCuit = guessCuit("12345678", Gender.Male); // "20-12345678-X"
const guessedCuitFemale = guessCuit("12345678", Gender.Female); // "27-12345678-X"

API Reference

validateCuit(input: string): CUIT | null

  • input: The CUIT string to validate.
  • Returns: A sanitized CUIT string if valid, otherwise null.

formatCuit(cuit: CUIT, separator: string = "-"): string

  • cuit: The sanitized and validated CUIT string.
  • separator: (Optional) Separator to use (default is -).
  • Returns: The formatted CUIT string.

guessCuit(dniInput: string, gender: Gender): string

  • dniInput: A DNI string to process.
  • gender: The gender type (Gender.Male or Gender.Female).
  • Returns: A guessed CUIT string in the format XX-XXXXXXXX-X.

Types

CUIT

A branded type representing a valid CUIT.

type CUIT = string & { _tag: "cuit" };

Gender

An enumeration for specifying gender when guessing a CUIT.

enum Gender {
  Male,
  Female,
}

License

MIT

Built and signed on
GitHub Actions

Report package

Please provide a reason for reporting this package. We will review your report and take appropriate action.

Please review the JSR usage policy before submitting a report.

Add Package

deno add jsr:@brielov/cuit

Import symbol

import * as cuit from "@brielov/cuit";
or

Import directly with a jsr specifier

import * as cuit from "jsr:@brielov/cuit";

Add Package

pnpm i jsr:@brielov/cuit
or (using pnpm 10.8 or older)
pnpm dlx jsr add @brielov/cuit

Import symbol

import * as cuit from "@brielov/cuit";

Add Package

yarn add jsr:@brielov/cuit
or (using Yarn 4.8 or older)
yarn dlx jsr add @brielov/cuit

Import symbol

import * as cuit from "@brielov/cuit";

Add Package

vlt install jsr:@brielov/cuit

Import symbol

import * as cuit from "@brielov/cuit";

Add Package

npx jsr add @brielov/cuit

Import symbol

import * as cuit from "@brielov/cuit";

Add Package

bunx jsr add @brielov/cuit

Import symbol

import * as cuit from "@brielov/cuit";