Skip to content

TypeScript library for utilities relevant to the Dominican Republic, such as Cedula, RNC, and NCF validation and formatting.

License

Notifications You must be signed in to change notification settings

Maikuh/dr-utils

Repository files navigation

Dominican Republic Utils

Release and NPM Publish Action

Language: English / Español

Dominican Republic Utils (hence, dr-utils) is a JavaScript library built with TypeScript for utilities relevant to the Dominican Republic, such as Cedula, RNC, and NCF validation and formatting.

Installation

# Via NPM
$ npm i dr-utils

# Via Yarn
$ yarn add dr-utils

# Via PNPM
$ pnpm add dr-utils

Usage

validateCedula(cedula: string)

import { validateCedula } from 'dr-utils'

const cedula = '40220579912'

const isCedulaValid = validateCedula(cedula) // true

validateRNC(rnc: string)

import { validateRNC } from 'dr-utils'

const rnc = '130500292'

const isRNCValid = validateRNC(rnc) // true

validateNCF(ncf: string)

import { validateNCF } from 'dr-utils'

const ncf = 'E319123402392'

const isNCFValid = validateNCF(ncf) // true

validatePhoneNumber(number: string)

import { validatePhoneNumber } from 'dr-utils'

const isPhoneNumberOneValid = validatePhoneNumber('8092201111') // true
const isPhoneNumberTwoValid = validatePhoneNumber('+1 (781) 575 4238') // false

formatCedula(cedula: string, removeOrAddDashes? = 'remove')

import { formatCedula } from 'dr-utils'

const noDashes = formatCedula('402-2057991-2') // 40220579912
const withDashes = formatCedula('40220579912', 'add') // 402-2057991-2

formatRNC(cedula: string, removeOrAddDashes? = 'remove')

import { formatRNC } from 'dr-utils'

const noDashes = formatRNC('130-50029-2') // 130500292
const withDashes = formatRNC('130500292', 'add') // 130-50029-2

formatPhoneNumber(number: string)

import { formatPhoneNumber } from 'dr-utils'

const phoneNumber = '8092201111'

const formatted = formatPhoneNumber(phoneNumber) // (809) 220-1111
const formattedInternational = formatPhoneNumber(phoneNumber, true) // +1 809 220 1111

Contributing

See CONTRIBUTING

Copyright

See LICENSE