UNPKG

aamva-parser

Version:

Plugin to parse AAMVA Drivers License Data from the PDF417 barcode

59 lines (58 loc) 2.06 kB
import { Gender, EyeColor, IssuingCountry, Truncation, HairColor, NameSuffix } from '../enums'; export class License { constructor(data) { this.firstName = null; this.lastName = null; this.middleName = null; this.expirationDate = null; this.issueDate = null; this.dateOfBirth = null; this.gender = Gender.Unknown; this.eyeColor = EyeColor.Unknown; this.height = null; this.streetAddress = null; this.city = null; this.state = null; this.postalCode = null; this.driversLicenseId = null; this.documentId = null; this.country = IssuingCountry.Unknown; this.middleNameTruncation = Truncation.None; this.firstNameTruncation = Truncation.None; this.lastNameTruncation = Truncation.None; this.streetAddressSupplement = null; this.hairColor = HairColor.Unknown; this.placeOfBirth = null; this.auditInformation = null; this.inventoryControlNumber = null; this.lastNameAlias = null; this.firstNameAlias = null; this.suffixAlias = null; this.suffix = NameSuffix.Unknown; this.version = null; this.pdf417 = null; Object.assign(this, data); } isExpired() { return this.expirationDate !== null && new Date() > this.expirationDate; } hasBeenIssued() { return this.issueDate !== null && new Date() > this.issueDate; } isAcceptable() { return (!this.isExpired() && this.hasBeenIssued() && this.expirationDate !== null && this.lastName !== null && this.firstName !== null && this.middleName !== null && this.issueDate !== null && this.dateOfBirth !== null && this.height !== null && this.streetAddress !== null && this.city !== null && this.state !== null && this.postalCode !== null && this.documentId !== null); } }