MRZ Paste Input

Validates a passport MRZ (ICAO 9303 TD3) check digit by check digit and catches OCR slips before details reach a booking or KYC form.

StopsHelps catch misread passport details before booking

Installation

pnpm dlx shadcn@latest add https://bollard-ui.vercel.app/r/mrz-paste-input.json

The files land in your project. They're yours to edit.

Usage

mrz-paste-input-usage.tsx
import { MrzPasteInput } from "@/components/ui/mrz-paste-input"

<MrzPasteInput value={text} onValueChange={setText} today={TODAY} />

What it catches

  • Wrong check digits for number, birth date, expiry, personal number and composite
  • OCR slips such as O for 0 and K for <
  • Swapped lines, CRLF and stray spaces
  • Likeliest fix for a wrong digit, cross-checked against the composite
  • Expired or soon-expiring passport

Props

MrzPasteInput props
PropTypeDefault
value

Controlled MRZ text.

string—
defaultValue

Initial text when uncontrolled.

string""
onValueChange

Called with the text on every edit or fix.

(value: string) => void—
onParse

Called when the parse result changes; `result.valid` is true once every check passes.

(result: MrzResult) => void—
today

"Today", for the expiry check and the birth-year century. Pass it for deterministic rendering.

Date—
locale

Locale for dates.

string"en-IN"
delay

Pause in ms before problems are read out after typing.

number700
messages

Any visible string; `fields` and `sexes` may be partial.

Partial<Omit<MrzMessages, "fields" | "sexes">> & { fields?: Partial<MrzMessages["fields"]>; sexes?: Partial<MrzMessages["sexes"]> }—

* required. Also accepts the native props of <textarea> (className, aria-*, data-*…), passed through to it.

Accessibility

  • Visible label; textarea has aria-invalid when invalid and is described by the result
  • Each check has an icon with role=img and an aria-label (checked, pending, failed)
  • Focus moves to the first fix after parsing

Only what the source does. Test with your own screen reader and content before shipping.

Limitations

This is a UX guard rail. Enforce on the server: Re-validate the MRZ and verify identity through your KYC provider on the server; don't log full MRZ lines.

  • Passports (TD3) only, not ID cards (TD1/TD2) or visas
  • Valid check digits don't prove the passport is genuine
  • Names in the MRZ are transliterated and may be truncated

Rules

Rules last verified:

Informational. Confirmed the 7-3-1 weighting and the composite over positions 1–10, 14–20 and 22–43. The soon-expiring threshold is a product choice, not ICAO. Copied components don't update themselves, so re-check after rule changes (see updating a component).

What it stops

Helps catch misread passport details before booking

Also known as

passport · mrz · icao 9303 · td3 · passport scan · kyc · flight booking · visa form

Dependencies

Pairs well with