parse

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

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

Splits input on \n, \r\n, or \r, drops leading empty lines, and trims trailing whitespace. Three lines of 30 characters read as TD1. Two lines of 36 read as TD2, or MRV-B if line 1 starts with V. Two lines of 44 read as TD3, or MRV-A if line 1 starts with V. Lowercase letters count as outside the MRZ alphabet.

Return

ParseResult.Success or ParseResult.PartialSuccess with the document, or ParseResult.Failure with MrzFormatNotDetected if the shape fits no format, or MrzCharacterSetViolation for the first character outside A-Z, 0-9, and <.

Parameters

input

the MRZ text.

referenceTime

the instant that picks the century of two-digit years and sets the date warnings. Defaults to the current time.


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.

Uses input as given. Reports and returns the same as parse with a string.

Return

the parse result, as for parse with a string.

Parameters

input

the MRZ lines, one element per line.

referenceTime

the instant that picks the century of two-digit years and sets the date warnings. Defaults to the current time.