Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rowellx68/valid-nhsnum
Validate NHS Numbers using the 11 modulo method. You can also generate NHS Numbers for testing.
https://github.com/rowellx68/valid-nhsnum
nhs nhs-number testing validation
Last synced: 2 days ago
JSON representation
Validate NHS Numbers using the 11 modulo method. You can also generate NHS Numbers for testing.
- Host: GitHub
- URL: https://github.com/rowellx68/valid-nhsnum
- Owner: rowellx68
- License: mit
- Created: 2021-08-18T19:30:57.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-06-14T15:55:26.000Z (7 months ago)
- Last Synced: 2024-12-06T22:21:25.789Z (21 days ago)
- Topics: nhs, nhs-number, testing, validation
- Language: TypeScript
- Homepage: https://rowellx68.github.io/valid-nhsnum/
- Size: 805 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# valid-nhsnum
![MIT](https://img.shields.io/badge/License-MIT-green?style=flat-square)
![CI](https://img.shields.io/github/actions/workflow/status/rowellx68/valid-nhsnum/publish.yml?style=flat-square&label=Build%20and%20Publish)
![NPM](https://img.shields.io/npm/v/valid-nhsnum?style=flat-square&label=Version)A zero dependency NHS Number validator and generator.
## Demo
Try the demo [here](https://rowellx68.github.io/valid-nhsnum/).
## Installation
```bash
pnpm i valid-nhsnum
```## API
#### `validate(value: string): boolean`
This method accepts a string and returns a boolean signifying the value's validity.
```ts
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.
```ts
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.
```ts
import { generateOne } from 'valid-nhsnum';// '082 379 5578'
generateOne(true);// '0823795578'
generateOne();
```## Links
- [NHS number format](https://en.wikipedia.org/wiki/NHS_number#Format)
- [What is an NHS number?](https://www.nhs.uk/using-the-nhs/about-the-nhs/what-is-an-nhs-number/)