README
🏷️ DNI Utils
Utilities to work with the Spanish DNI
🥪 Install
$ npm install @muxed/dni-utils
🎉 Usage
Import the instaled Package
const dni = require('@muxed/dni-utils');
Create a class constructor (if you need check the Support number for NIE, the second parameter acepted)
// Start the class with DNI
let validator = new dni.validator('22414222P');
// Start the class with NIE and SUPPORT NUMBER
let validator = new dni.validator('X2414222P','E24210042');
Functions availables
Check validity (any NIE, NIF or CIF). Return true
or false
.
validator.isValid();
Check validity (NIE, NIF or CIF) . Return true
or false
.
validator.isNif();
validator.isNie();
validator.isCif();
Return an Object with society type and province. Format: { society: String, province: String }
validator.dataNif();
Return the type of DNI (NIE
, NIF
or CIF
) or INVALID
.
validator.typeDNI();
Check Support Number (for NIE). Return true
or false
.
validator.validSupportNumber();
Sanitize support number (NIE). Return formated Number E00000001
.
validator.sanitizeSupportNumber(); // Return the Support Number (NIE) in E00000001 format
IMPORTANT: Obsolete CIFs isn't supported (return INVALID)
🟢 Testing
Install the Jest dependencies if not in global
$ npm install
Run the tests
$ npm test
🍰 Contributing
Please read CONTRIBUTING for details on our CODE OF CONDUCT, and the process for submitting pull requests.
☕️ Buy Me a Coffee
📑 License
MIT © MuXeD
⌨️ with ❤︎ by MuXeD