Skip to content

Commit

Permalink
Merge branch 'release/1.1.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
spikeheap committed Sep 8, 2015
2 parents 45f7fed + 9f3f886 commit ac1577a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- "0.12"
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# NHS number validator (JS)
[![Build Status](https://travis-ci.org/spikeheap/nhs-number-validator.svg?branch=develop)](https://travis-ci.org/spikeheap/nhs-number-validator)

A simple NHS number validator, following the process described in the [NHS Data Dictionary](http://www.datadictionary.nhs.uk/data_dictionary/attributes/n/nhs/nhs_number_de.asp?shownav=0?query=%22nhs+number%22&rank=100&shownav=1).

Expand All @@ -18,6 +19,34 @@ bower install --save nhs-number-validator

## Usage

##### Command line / terminal

To run the interactive validation tool, install the NPM module globally:

```bash
npm install -g nhs-number-validator
```

and `nhs-number-validator` will be added to your path:

```bash
$ nhs-number-validator
Enter NHS numbers to validate, Ctrl-D to exit
> 123
*INVALID
> 2983396339
VALID
```

You can also install the tool for a single project, and just reference the executable in your project:

```bash
npm install nhs-number-validator
./node_modules/.bin/nhs-number-validator
# or
`npm bin`/nhs-number-validator
```

##### Node/Browserify

For environments supporting `require`/`exports`:
Expand Down Expand Up @@ -55,10 +84,10 @@ Pull requests, issues, and questions are all welcome.

Some useful commands:

* `npm run`: run the validator CLI.
* `npm test`: run the test suite.
* `npm run test-watch --silent`: watch for changes and run the test suite each time.
* `npm run lint --silent`: run the code linter.
* `npm run cli`: run the validator CLI.

NPM is overly verbose [at the moment](https://github.com/npm/npm/issues/5452), hence the additional `--silent` to suppress the unnecessary noise.

Expand Down
18 changes: 18 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env node

var rl = require('readline').createInterface(process.stdin, process.stdout);
var validator = require('./index.js');

console.log('Enter NHS numbers to validate, Ctrl-D to exit');

rl.setPrompt('> ');
rl.prompt();

rl.on('line', function(line) {
var result = validator.validate(line);
console.log(result ? ' VALID' : ' *INVALID')
rl.prompt();

}).on('close', function() {
process.exit(0);
});
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"name": "nhs-number-validator",
"version": "1.0.1",
"version": "1.1.0",
"description": "Validate NHS numbers in various guises",
"main": "index.js",
"scripts": {
"test": "./node_modules/.bin/jasmine-node .",
"test-watch": "./node_modules/.bin/jasmine-node . --autotest",
"lint": "./node_modules/.bin/jshint *.js"
"lint": "./node_modules/.bin/jshint *.js",
"cli": "./cli.js"
},
"bin": {
"nhs-number-validator": "./cli.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit ac1577a

Please sign in to comment.