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.
# Via NPM
$ npm i dr-utils
# Via Yarn
$ yarn add dr-utils
# Via PNPM
$ pnpm add dr-utils
import { validateCedula } from 'dr-utils'
const cedula = '40220579912'
const isCedulaValid = validateCedula(cedula) // true
import { validateRNC } from 'dr-utils'
const rnc = '130500292'
const isRNCValid = validateRNC(rnc) // true
import { validateNCF } from 'dr-utils'
const ncf = 'E319123402392'
const isNCFValid = validateNCF(ncf) // true
import { validatePhoneNumber } from 'dr-utils'
const isPhoneNumberOneValid = validatePhoneNumber('8092201111') // true
const isPhoneNumberTwoValid = validatePhoneNumber('+1 (781) 575 4238') // false
import { formatCedula } from 'dr-utils'
const noDashes = formatCedula('402-2057991-2') // 40220579912
const withDashes = formatCedula('40220579912', 'add') // 402-2057991-2
import { formatRNC } from 'dr-utils'
const noDashes = formatRNC('130-50029-2') // 130500292
const withDashes = formatRNC('130500292', 'add') // 130-50029-2
import { formatPhoneNumber } from 'dr-utils'
const phoneNumber = '8092201111'
const formatted = formatPhoneNumber(phoneNumber) // (809) 220-1111
const formattedInternational = formatPhoneNumber(phoneNumber, true) // +1 809 220 1111
See CONTRIBUTING
See LICENSE