valid-nhsnum
TypeScript icon, indicating that this package has built-in type declarations

1.0.4 • Public • Published

valid-nhsnum

MIT CI NPM

A zero dependency NHS Number validator and generator.

Demo

Try the demo here.

Installation

pnpm i valid-nhsnum

API

validate(value: string): boolean

This method accepts a string and returns a boolean signifying the value's validity.

import { validate } from 'valid-nhsnum';

// true
validate('098 357 6548');

generate(count: number, formatted?: boolean): string[]

This method is useful for generating a list of NHS numbers that can be used for testing.

It has an optional boolean parameter that pre-formats the NHS numbers if true is passed in.

import { generate } from 'valid-nhsnum';

// ['035 469 6505', '082 379 5578']
generate(2, true);

// ['0354696505', '0823795578']
generate(2);

generateOne(formatted?: boolean): string

This method generates a single NHS number with an optional boolean parameter that if set to true would format the string.

import { generateOne } from 'valid-nhsnum';

// '082 379 5578'
generateOne(true);

// '0823795578'
generateOne();

Links

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.4
    21
    • latest

Version History

Package Sidebar

Install

npm i valid-nhsnum

Weekly Downloads

42

Version

1.0.4

License

MIT

Unpacked Size

10.4 kB

Total Files

13

Last publish

Collaborators

  • rowellx68