validate

fun validate(document: MrzDocument, referenceTime: Instant = Clock.System.now()): ValidationResult

Validates a parsed document and returns its validation failures and warnings.

Reads the field text from document.rawLines and the printed check digits from document.commonFields.checkDigits. Reports MrzExpiryDatePast only when the expiry date is strictly earlier than the reference date, and MrzExpiryDateImplausiblyFar when it is more than 10 years after it. Both compare UTC dates. Reports MrzExpiryDateCenturyNotInferred instead when the expiry parts are digits that form a real date but neither the 2000s nor the 1900s puts the year from 10 years before to 50 years after the reference year, so there is no expiry date to compare. For a TD3 document whose document code starts with P and whose second character is not a letter of the Part 4 table (P, E, D, O, R, T, S, L, M; U is also left out, the designated code for single sheet documents), the filler < included, also reports MrzExpiryDateAfterNonHarmonizedPassportLimit when the computed expiry date is on or after 2038-01-01 (ICAO Doc 9303 Part 4, section 4.4); never when the expiry century is unknown.

If document.rawLines cannot be read as the document's format, no check runs and structuralFailure says why: MrzInvalidLength when the line count or a line length does not fit the format (empty rawLines included), or MrzCharacterSetViolation for the first character outside A-Z, 0-9, and <. A document from MrzParser always passes.

Return

the validation failures and warnings, or the reason rawLines could not be read in structuralFailure.

Parameters

document

the document to check.

referenceTime

the instant that sets the date checks. Defaults to the current time.


fun validate(input: String, referenceTime: Instant = Clock.System.now()): ValidationResult

Parses an MRZ string, detecting the format, and returns its validation result.

Runs MrzParser.parse and reports what the parser attached to the result. If the parse fails, structuralFailure holds the parse error and validationFailures and warnings are empty.

Return

the validation failures and warnings, or the parse error in structuralFailure.

Parameters

input

the MRZ text.

referenceTime

the instant that sets the date checks. Defaults to the current time.


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

Parses pre-split MRZ lines, detecting the format, and returns their validation result.

Reports the same as validate with a string.

Return

the validation failures and warnings, or the parse error in structuralFailure.

Parameters

input

the MRZ lines, one element per line.

referenceTime

the instant that sets the date checks. Defaults to the current time.


fun validate(input: String, format: MrzFormat, referenceTime: Instant = Clock.System.now()): ValidationResult

Parses an MRZ string as the given format and returns its validation result.

Runs the format-specific parser. A line count or line length that does not fit format gives MrzInvalidLength in structuralFailure, not MrzFormatNotDetected.

Return

the validation failures and warnings, or the parse error in structuralFailure.

Parameters

input

the MRZ text.

format

the format to read input as.

referenceTime

the instant that sets the date checks. Defaults to the current time.


fun validate(@ObjCName(name = "lines") input: List<String>, format: MrzFormat, referenceTime: Instant = Clock.System.now()): ValidationResult

Parses pre-split MRZ lines as the given format and returns their validation result.

Reports the same as validate with a string and a format.

Return

the validation failures and warnings, or the parse error in structuralFailure.

Parameters

input

the MRZ lines, one element per line.

format

the format to read input as.

referenceTime

the instant that sets the date checks. Defaults to the current time.