aamva-parser
Version:
Plugin to parse AAMVA Drivers License Data from the PDF417 barcode
55 lines (54 loc) • 1.62 kB
JavaScript
// Standard FieldMapping implementation based on the AAMVA Version 8 standard
export class FieldMapper {
constructor() {
// A list of AAMVA field designator mappings (e.g. "firstName" => "DAC")
this._fields = {
firstName: "DAC",
lastName: "DCS",
middleName: "DAD",
expirationDate: "DBA",
issueDate: "DBD",
dateOfBirth: "DBB",
gender: "DBC",
eyeColor: "DAY",
height: "DAU",
streetAddress: "DAG",
city: "DAI",
state: "DAJ",
postalCode: "DAK",
driversLicenseId: "DAQ",
documentId: "DCF",
country: "DCG",
middleNameTruncation: "DDG",
firstNameTruncation: "DDF",
lastNameTruncation: "DDE",
streetAddressSupplement: "DAH",
hairColor: "DAZ",
placeOfBirth: "DCI",
auditInformation: "DCJ",
inventoryControlNumber: "DCK",
lastNameAlias: "DBN",
firstNameAlias: "DBG",
suffixAlias: "DBS",
suffix: "DCU",
weight: "DAW"
};
}
// Getter for fields
get fields() {
return this._fields;
}
// Setter for fields
set fields(newFields) {
this._fields = newFields;
}
/**
* Determine the AAMVA field designator for a particular human-readable key.
*
* @param key - The human-readable key
* @returns The AAMVA field designator
*/
fieldFor(key) {
return this.fields[key] || "";
}
}