MrzParser

object MrzParser

Parses MRZ text into an io.lightine.tessera.mrz.model.MrzDocument per ICAO Doc 9303.

Every entry point returns a ParseResult. The parser runs the validator on each document it builds and puts the outcome on the result metadata. It reports check digit mismatches, dates that are not in the calendar, and sex characters outside M, F, <, and X as validation failures. It reports MrzExpiryDatePast, MrzExpiryDateImplausiblyFar, MrzExpiryDateCenturyNotInferred, MrzExpiryDateAfterNonHarmonizedPassportLimit, MrzNameTruncated, MrzUnknownCountryCode, MrzUnknownDocumentTypeCode, MrzSexCharacterX, and MrzPersonalNumberCheckDigitFiller as warnings.

Every sex character other than M and F, including X and Z, maps to Sex.UNSPECIFIED; rawSex keeps the printed character. The reading method of every result is ReadMethod.BACKEND_STRING_INPUT.

Since

0.1.0

Functions

Link copied to clipboard
fun parse(input: String, referenceTime: Instant = Clock.System.now()): ParseResult

Parses an MRZ string, detecting the format from its line count and line lengths.

fun parse(@ObjCName(name = "lines") input: List<String>, referenceTime: Instant = Clock.System.now()): ParseResult

Parses pre-split lines, detecting the format from the line count and line lengths.

Link copied to clipboard
fun parseMRVA(input: String, referenceTime: Instant = Clock.System.now()): ParseResult

Parses an MRZ string as an MRV-A (Type-A visa) MRZ: 2 lines of 44 characters.

fun parseMRVA(@ObjCName(name = "lines") input: List<String>, referenceTime: Instant = Clock.System.now()): ParseResult

Parses pre-split lines as an MRV-A (Type-A visa) MRZ: 2 lines of 44 characters.

Link copied to clipboard
fun parseMRVB(input: String, referenceTime: Instant = Clock.System.now()): ParseResult

Parses an MRZ string as an MRV-B (Type-B visa) MRZ: 2 lines of 36 characters.

fun parseMRVB(@ObjCName(name = "lines") input: List<String>, referenceTime: Instant = Clock.System.now()): ParseResult

Parses pre-split lines as an MRV-B (Type-B visa) MRZ: 2 lines of 36 characters.

Link copied to clipboard
fun parseTD1(input: String, referenceTime: Instant = Clock.System.now()): ParseResult

Parses an MRZ string as a TD1 (identity card) MRZ: 3 lines of 30 characters.

fun parseTD1(@ObjCName(name = "lines") input: List<String>, referenceTime: Instant = Clock.System.now()): ParseResult

Parses pre-split lines as a TD1 (identity card) MRZ: 3 lines of 30 characters.

Link copied to clipboard
fun parseTD2(input: String, referenceTime: Instant = Clock.System.now()): ParseResult

Parses an MRZ string as a TD2 MRZ: 2 lines of 36 characters.

fun parseTD2(@ObjCName(name = "lines") input: List<String>, referenceTime: Instant = Clock.System.now()): ParseResult

Parses pre-split lines as a TD2 MRZ: 2 lines of 36 characters.

Link copied to clipboard
fun parseTD3(input: String, referenceTime: Instant = Clock.System.now()): ParseResult

Parses an MRZ string as a TD3 (passport) MRZ: 2 lines of 44 characters.

fun parseTD3(@ObjCName(name = "lines") input: List<String>, referenceTime: Instant = Clock.System.now()): ParseResult

Parses pre-split lines as a TD3 (passport) MRZ: 2 lines of 44 characters.