nationid - v2.2.1
    Preparing search index...

    Function validateMrzNumber

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

    Each function is a pure mathematical primitive with cited spec.

    • Validate a 9-char document number + 1-char check digit (10 chars total).

      Returns true iff the input is exactly 10 chars, the body matches the MRZ alphabet ([0-9A-Z<]{9}), the check digit is a single decimal, and mrzCheckDigit(input.slice(0, 9)) === Number(input[9]).

      Never throws — invalid input simply returns false.

      Parameters

      • input: string

        10-char string: 9 MRZ-alphabet chars + 1 decimal check digit.

      Returns boolean

      true if the input is a well-formed, checksum-correct MRZ number.

      import { validateMrzNumber, toMrzField9, mrzCheckDigit } from "nationid/algorithms";

      const body = toMrzField9("L898902C"); // "L898902C<"
      const full = body + String(mrzCheckDigit(body));
      validateMrzNumber(full); // true