Skip to content

juananmuxed/dni-utils

Repository files navigation

🏷️ DNI Utils

Utilities to work with the Spanish DNI

npm (scoped) npm bundle size (scoped) License GitHub Workflow Status

Discord

🥪 Install

$ npm install @muxed/dni-utils

🎉 Usage

Import the functions you want

import {
  isCif,
  isNie,
  isNif,
} from "./../src/modules/validator";

Functions available

const dni = '54148871V';
// Check validity (any NIE, NIF or CIF). Return `true` or `false`.
isValid(dni);
// Check validity (NIE, NIF or CIF) . Return `true` or `false`.
isNif(dni);
isNie(dni);
isCif(dni);
// Return an Object with society type and province. Format: `{ society: String, province: String }`
dataNif(dni);
// Return the type of DNI (`NIE`, `NIF` or `CIF`) or `INVALID`.
typeDNI(dni);

IMPORTANT: Obsolete CIFs isn't supported (return INVALID)

🟢 Testing

Install the Jest dependencies if not in global

$ npm install

Run the tests

$ npm run test

🍰 Contributing

Please read CONTRIBUTING for details on our CODE OF CONDUCT, and the process for submitting pull requests.

☕️ Buy Me a Coffee

ko-fi

📑 License

MIT © MuXeD

⌨️ with ❤︎ by MuXeD