@edyspider/validate-nif
TypeScript icon, indicating that this package has built-in type declarations

1.7.8 • Public • Published

Validate-NIF

A simple npm package to validate Portuguese fiscal identification numbers (NIF).


Installation

npm i @edyspider/validate-nif

Usage

Javascript

const { validateNIF, randomNIF } = require('@edyspider/validate-nif');

const validNIF = '123456789';
const invalidNIF = '999999999';
const randNIF = randomNIF();

console.log(`Is ${validNIF} a valid NIF?`, validateNIF(validNIF));
console.log(`Is ${invalidNIF} a valid NIF?`, validateNIF(invalidNIF));
console.log(`Generated random NIF: ${randNIF}`);
console.log(`Is generated NIF valid?`, validateNIF(randNIF));
Is 123456789 a valid NIF? true
Is 999999999 a valid NIF? false
Generated random NIF: ?????????
Is generated NIF valid? true

Typescript

import { validateNIF, randomNIF } from '@edyspider/validate-nif';

const isValidNIF = validateNIF('123456789');
const isInvalidNIF = validateNIF('999999999');
const newRandNIF = randomNIF();

console.log('NIF is valid:', isValidNIF);
console.log('NIF is invalid:', isInvalidNIF);
console.log('New random NIF:', newRandNIF);
Is 123456789 a valid NIF? true
Is 999999999 a valid NIF? false
New random NIF: ?????????

Known Issues

Authors

License

Package Sidebar

Install

npm i @edyspider/validate-nif

Weekly Downloads

6

Version

1.7.8

License

MIT

Unpacked Size

5.54 kB

Total Files

5

Last publish

Collaborators

  • edyspider