# driver-license-validator

> Validate driver license numbers.

Latest version **3.1.1** (published 2022-01-08) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install driver-license-validator
pnpm add driver-license-validator
yarn add driver-license-validator
bun add driver-license-validator
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 3.1.1 |
| Published | 2022-01-08 |
| First published | 2019-04-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | ^12.20.0 \|\| ^14.13.1 \|\| >=16.0.0 |
| Dependencies | 0 |
| Unpacked size | 29.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Justin Lettau |
| Maintainers | justinlettau |
| Keywords | driver-license, drivers-license, validation, validator |

## Links

- npm: https://www.npmjs.com/package/driver-license-validator
- Repository: https://github.com/justinlettau/driver-license-validator
- Issues: https://github.com/justinlettau/driver-license-validator/issues
- npm.io page: https://npm.io/package/driver-license-validator

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 3.1.1 (latest) — 2022-01-08
- 3.1.0 — 2021-12-13
- 3.0.0 — 2021-10-28
- 2.0.2 — 2021-05-19
- 2.0.1 — 2021-03-23
- 2.0.0 — 2020-11-23
- 1.0.0 — 2019-04-16

## README

[![NPM Version](https://badge.fury.io/js/driver-license-validator.svg)](https://badge.fury.io/js/driver-license-validator)
[![CI](https://github.com/justinlettau/driver-license-validator/workflows/CI/badge.svg)](https://github.com/justinlettau/driver-license-validator/actions)
[![codecov](https://codecov.io/gh/justinlettau/driver-license-validator/branch/master/graph/badge.svg)](https://codecov.io/gh/justinlettau/driver-license-validator)

# Driver License Validator

Validate driver license numbers.
Formats based on [https://ntsi.com/drivers-license-format/](https://ntsi.com/drivers-license-format/).

# Table of Contents

- [Installation](#installation)
- [Usage](#usage)
- [Development](#development)

# Installation

```bash
npm install driver-license-validator --save
```

# Usage

```js
import { getMatches, isValid } from 'driver-license-validator';

isValid('A1234567');
// => true

isValid('invalid_dl');
// => 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('invalid_dl');
// => 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
```

---
_Source: https://npm.io/package/driver-license-validator · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
