nationid - v2.2.1
    Preparing search index...

    Function mrzCheckDigit

    Public algorithm primitives. Tree-shakable subpath: nationid/algorithms.

    Each function is a pure mathematical primitive with cited spec.

    • Compute the MRZ check digit for a string per ICAO 9303 (cyclic weights [7, 3, 1], mod 10).

      Used as a building block to validate the document number, DOB, expiry, and the final composite check digit of an MRZ line.

      Parameters

      • input: string

        A string drawn from the MRZ alphabet ([0-9A-Z<]*).

      Returns number

      The check digit in [0, 9]. Empty string returns 0.

      ICAO_INVALID_CHAR if input contains any character outside the MRZ alphabet.

      import { mrzCheckDigit } from "nationid/algorithms";

      mrzCheckDigit("L898902C<"); // 3 (ICAO 9303 worked example)