Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including @deploythenscotch/national-id-validator with all npm packages installed. Try it out:

var nationalIdValidator = require("@deploythenscotch/national-id-validator")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

@deploythenscotch/national-id-validator v1.0.1

Helper collections for validating and creating mock national ID numbers.

National Id

Allows you to both validate and create mock national IDs.


yarn add @deploythenscotch/national-id-validator


npm install @deploythenscotch/national-id-validator



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


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


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
RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free