Coder Social home page Coder Social logo

parse-usdl's Introduction

parse-usdl

parse Pdf417 barcode data from US driver licenses

Usage

import { parse } from 'parse-usdl'

const code =
`@

ANSI 636001070002DL00410392ZN04330047DLDCANONE
DCBNONE
DCDNONE
DBA08312013
DCSMichael
DACM
DADMotorist
DBD08312013
DBB08312013
DBC1
DAYBRO
DAU064 in
DAG2345 ANYWHERE STREET
DAIYOUR CITY
DAJNY
DAK123450000
DAQNONE
DCFNONE
DCGUSA
DDEN
DDFN
DDGN
`
const data = parse(code)
console.log(JSON.stringify(data, null, 2))

// {
//   "jurisdictionRestrictionCodes": "NONE",
//   "jurisdictionEndorsementCodes": "NONE",
//   "dateOfExpiry": 1377921600000,
//   "lastName": "Michael",
//   "firstName": "M",
//   "middleName": "Motorist",
//   "dateOfIssue": 1377921600000,
//   "dateOfBirth": 1377921600000,
//   "sex": "M",
//   "eyeColor": "BRO",
//   "height": "064 in",
//   "addressStreet": "2345 ANYWHERE STREET",
//   "addressCity": "YOUR CITY",
//   "addressState": "NY",
//   "addressPostalCode": "123450000",
//   "documentNumber": "NONE",
//   "documentDiscriminator": "NONE",
//   "issuer": "USA",
//   "lastNameTruncated": "N",
//   "firstNameTruncated": "N",
//   "middleNameTruncated": "N"
// }
// ~/Co

Optional Parameters

suppressErrors

Prevent a hard error in the case of a bad code provided. All valid codes will be parsed and returned.

const options = {
    suppressErrors: false
}

parse-usdl's People

Contributors

alexanderkaplunsky avatar bgerhards avatar chancesmith avatar mvayngrib avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

parse-usdl's Issues

Issue when parsing name containing code key

Hi everyone i'm seeing the following issue when the first name (or any other value) contains a key name, like for example ADAN which contains DAN key, then the name parsed is the following response:

{
  "documentNumber": "xxxxxx",
  "lastName": "MANTILLA",
  "lastNameTruncated": "N",
  "firstName": "A",
  "firstNameTruncated": "N",
  "middleName": "ELIECER",
  "middleNameTruncated": "N",
  "jurisdictionVehicleClass": "C",
  "jurisdictionRestrictionCodes": "01",
  "jurisdictionEndorsementCodes": "NONE",
  "dateOfIssue": "06/01/2018",
  "dateOfBirth": "06/03/1987",
  "dateOfExpiry": "06/03/2022",
  "sex": "M",
  "height": "064 IN",
  "eyeColor": "GRN",
  "addressStreet": "xxxxx",
  "addressCity": "xxxx",
  "complianceType": "N",
  "addressPostalCode": "xxxxxxx",
  "documentDiscriminator": "xxxxxx",
  "issuer": "USA",
  "weightLb": "130",
  "hairColor": "BRO",
  "inventoryControlNumber": "xxxxxx"
}

Do you guys know how to handle this race cases ?

Change in California drivers license format

It seems the format for the codes of the new drivers license in California (expire in 2023 instead of 2020) have changed a bit. The drivers license number seems to be located under DCK, previously it was located under DAQ. I made an quick and dirty adjustment to the parseUsdl.js file to accommodate for this in my local environment:

Under line 22:

/////////////////////////////////////////////
// Switch values if true, of value and key //
/////////////////////////////////////////////
if (isNewDl(code, line)) value = line.slice(8, 16), key = 'documentNumber'

Under line 43:

/////////////////////////////
// Determine if DCK code's //
// key is documentNumber   //
/////////////////////////////
const isNewDl = (code, line) => (code === "DCK" && line.slice(0, 8).match('DCK[0-9][0-9][0-9][0-9][0-9]') !== null)

Just wanted to bring attention to this.

Parsing new line characters

I'm working with the L-Tron LTC4910 scanner in the USB Keyboard mode. When scanning a driver's license I get a string formatted as below:

@ ANSI 636024070001DL00310247DLDAQ12345678DCSDOEDDENDACJANEDDFNDADCDDGUDCADDCBNONEDCDNONEDBD02012018DBB01011940DBA01012022DBC2DAU070 inDAYHAZDAG10 SOME STREETDAICITYDAJVTDAK123450000 DCF123451234544DCGUSADAW170DAHNONEDDAFDDB02202013DDK1

The only new line characters are after the @ and ANSI. If I manually add new lines after each section, the string parses but if I don't, the string returns an empty object. I believe the prefixes are different for each state so I'm unsure of how to parse the string programmatically. Is there a way to parse the data without requiring the new line characters?

Thanks for the help.

ES6 code is not bundle safe

Hello, This is a nice little utility! We noticed that it uses let and const (ES6) and is breaking our webpack build due to the fact that Uglify JS cannot minify ES6 code. Super easy to fork into our own function but just wanted to give a heads up. Thanks!

Error when parsing Ontario driver's license

Ontario driver's licenses include the DCT field, which is where the first name is placed. This library is missing that field and errors out on Ontario licenses. It should be an easy fix.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.