Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nhs-validation

JoshWalshaw16.1kMIT1.0.0TypeScript support: included

Allows the validation and generation of NHS Numbers

nhs, nhs numbers, nhs number, nhs number validation, nhs validation, nhs validate

readme

NHS Validation

npm_version vulnerabilities testing install size

This package allows you to validate if a string provided, has the potential to be a valid NHS Number - as well as generate an example NHS compliant number.

NHS numbers follow a slightly modified version of Modulus 11 algorithm. Specific information on the format for the NHS can be found here.

Current basic usage is as follows.

import { NHSNumber } from 'nhs-validation'

const nhsNumber = NHSNumber.generate();

console.log('Is valid? ', NHSNumber.validate(nhsNumber) ); // true
console.log('Is valid? ', NHSNumber.validate('671 668 9966') ); // true
console.log('Is valid? ', NHSNumber.validate('000 000 0001') ); // false