Socket
Book a DemoInstallSign in
Socket

driver-license-validator

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

driver-license-validator

Validate driver license numbers.

latest
Source
npmnpm
Version
3.1.1
Version published
Weekly downloads
4.4K
-3.6%
Maintainers
1
Weekly downloads
 
Created
Source

NPM Version CI codecov

Driver License Validator

Validate driver license numbers. Formats based on https://ntsi.com/drivers-license-format/.

Table of Contents

Installation

npm install driver-license-validator --save

Usage

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:

OptionTypeDescriptionDefault
countrystringCountry to use.US
statesstring or string[]State(s) to filter results to.n/a
ignoreCasebooleanTrue to ignore case.false

Development

npm install
npm run build

Keywords

driver-license

FAQs

Package last updated on 08 Jan 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts