Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dni-js

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dni-js

Compute and validate a Spanish DNI/NIE number

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
92
decreased by-50.27%
Maintainers
1
Weekly downloads
 
Created
Source

dni-js

Compute and validate a Spanish DNI/NIE numbers as described here.

Build Status npm version

Install

$ npm install dni-js

Usage

Validation is based on this document.

const dni = require('dni-js');

dni.isValid('12345678-Z'); // => true

API

.dni (number|string)

Returns a DNI number with the control digit appended in the format 12345678-Z. If the input is invalid, returns null.

.nie (number|string)

Returns a NIE number with the control digit appended in the format X1234567-L. If the input is invalid, returns null.

.getControlDigit (number|string)

Returns the control digit for the input.

.getLetter (number|string)

Alias for getControlDigit.

.isValid (string)

Returns true or false by validating the input.

.normalize (string)

Given a string input, it returns a normalized valid DNI. When input is either not a string, or invalid, it returns null. For example:

dni.normalize('   12 34 56 7 8-z'); // 12345678-Z

License

MIT

Keywords

FAQs

Package last updated on 04 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc