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.
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
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
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"
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"
- input: The CUIT string to validate.
- Returns: A sanitized CUIT string if valid, otherwise
null
.
- cuit: The sanitized and validated CUIT string.
- separator: (Optional) Separator to use (default is
-
). - Returns: The formatted CUIT string.
- dniInput: A DNI string to process.
- gender: The gender type (
Gender.Male
orGender.Female
). - Returns: A guessed CUIT string in the format
XX-XXXXXXXX-X
.
A branded type representing a valid CUIT.
type CUIT = string & { _tag: "cuit" };
An enumeration for specifying gender when guessing a CUIT.
enum Gender {
Male,
Female,
}
MIT