Skip to content
/ cuit Public

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

License

Notifications You must be signed in to change notification settings

brielov/cuit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@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

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published