Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

@deploythenscotch/national-id-validator

1.0.1 • Public • Published

National Id

Allows you to both validate and create mock national IDs.

Installation

yarn add @deploythenscotch/national-id-validator

or

npm install @deploythenscotch/national-id-validator

Usage

ES5

const nationalID = require('@deploythenscotch/national-id-validator');
const isValidID = nationalID.isValid('18100749331');

ES2016+

import nationalID from @deploythenscotch/national-id-validator;
const isValidID = nationalID.isValid('18100749331');

Methods

import nationalID from @deploythenscotch/national-id-validator;
 
// Check if the ID is valid. Works with both "fødselsnummer" and "d-nummer".
// Returns true || false.
nationalID.isValid('18100749331'); // true;
 
// Get the type based on the ID.
// Returns 'FNUMBER' || 'DNUMBER'
nationalID.getTypeFromID('18100749331'); // 'FNUMBER'
 
// Get the gender based on the ID.
// Returns 'MALE' OR 'FEMALE'
nationalID.getGenderFromID('18100749331'); // 'MALE'
 
// Get the date from ID. Will return a native date object.
// Returns Date object
nationalID.getDateFromID('18100749331'); // Fri Oct 18 1907 01:00:00 GMT+0100

Install

npm i @deploythenscotch/national-id-validator

DownloadsWeekly Downloads

4

Version

1.0.1

License

MIT

Unpacked Size

227 kB

Total Files

69

Last publish

Collaborators

  • avatar