driver-license-validator

Validate driver license numbers.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
driver-license-validator
6113.1.12 years ago5 years agoMinified + gzip package size for driver-license-validator in KB

Readme

NPM Version CI codecov
Driver License Validator
Validate driver license numbers. Formats based on https://ntsi.com/drivers-license-format/.
Table of Contents
Installation
```bash npm install driver-license-validator --save ```
Usage
```js import { getMatches, isValid } from 'driver-license-validator'; isValid('A1234567'); // => true isValid('invaliddl'); // => false getMatches('A1234567'); // => // { description: '1 letter followed by 1-8 numbers', state: 'AZ' }, // { description: '1 letter followed by 7 numbers', state: 'CA' }, // { description: '1 letter followed by 5-9 numbers', state: 'MO' }, // { description: '1 letter followed by 6-8 numbers', state: 'NE' }, // { description: '1 letter followed by 7 numbers', state: 'NY' }, // { description: '1 letter followed by 4-8 numbers', state: 'OH' } // getMatches('A1234567', { states: 'NY' }); // => // { description: '1 letter followed by 7 numbers', state: 'NY' } // getMatches('A1234567', { states: 'NY', 'OH' }); // => // { description: '1 letter followed by 7 numbers', state: 'NY' }, // { description: '1 letter followed by 4-8 numbers', state: 'OH' } // getMatches('A123456789', { country: 'CA' }); // => // { description: '1 letter followed by 9 numbers', state: 'NL' } // getMatches('invaliddl'); // => null ``` Options: | Option | Type | Description | Default | | ------------ | ---------------------- | ------------------------------ | ------- | | country | string | Country to use. | US | | states | string or string[] | State(s) to filter results to. | n/a | | ignoreCase | boolean | True to ignore case. | false |
Development
``` npm install npm run build ```