Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@concorde2k/ccdriverlicensevalidator

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@concorde2k/ccdriverlicensevalidator

A utility to validate a driver license number for a given state code

  • 1.1.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
3
Weekly downloads
 
Created
Source

Installation

npm i @concorde2k/ccDriverLicenseValidtor

Usage

Validate license number

Call the validator with the license number to be tested, and the state abbreviation. It will return TRUE if the format is valid, FALSE if it is not. For example:

const validator = require('@concorde2k/ccDriverLicenseValidtor');

// validate license number for the state of Pennsylvania
const result = validator.validateLicenseNumber('12345678', 'PA');
if( result) {
  // passed
} else {
  // failed
}

Get license format descriptions

The descriptions of a state's valid license formats can be retrieved (in order to display them to the end user, etc.).

const licenseFormats = validator.getLicenseFormatDescriptions('PA');

Override standard rules

If desired, pass an additional parameter with the validation rules:

const result = validator.validateLicenseNumber('12345678', 'PA', rules);
const licenseFormats = validator.getLicenseFormatDescriptions('PA', rules);

The rules object is a JSON object with a property for each state, consisting of a rule (a string containing a RegExp), and a description (an array of strings). For example:

{
  "AL": {
    "rule": "^[0-9]{1,8}$",
    "description": [
      "1-8 Numeric"
    ]
  },
  "AK": {
    "rule": "^[0-9]{1,7}$",
    "description": [
      "1-7 Numbers"
    ]
  },
  "AZ": {
    "rule": "(^[A-Z]{1}[0-9]{1,8}$)|(^[A-Z]{2}[0-9]{2,5}$)|(^[0-9]{9}$)",
    "description": [
      "1 Alpha + 1-8 Numeric",
      "2 Alpha + 2-5 Numeric",
      "9 Numeric"
    ]
  },
 .
 .
 .
}

FAQs

Package last updated on 05 Oct 2020

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc