Passport

Validator, formatter, and masker for Indian Passport numbers.

Indian Passport numbers are issued by the Ministry of External Affairs (MEA) and serve as the primary international travel document and a widely accepted proof of identity and address for Indian citizens.

Format: [A-Z]\d{7} — 1 uppercase letter followed by 7 digits (8 characters total).

  • Character 1: uppercase letter (passport series prefix, assigned by MEA)

  • Characters 2–8: 7-digit serial number (padded with leading zeros as needed)

No checksum: The Ministry of External Affairs has not published a public checksum algorithm for Indian passport numbers. Validation is structural (format + length) only.

Passport is Private government ID PII (§3.5). Mask before logging or displaying in UI. See mask for PII-safe display options.

Accepted input forms (all normalised before validation):

  • Raw uppercase: "M1234567"

  • Lowercase: "m1234567" — normalised to uppercase

  • With spaces: "M 1234567" — internal whitespace stripped

  • Whitespace padded: " M1234567 " — leading/trailing whitespace trimmed

Reference: Ministry of External Affairs (MEA) passport number format. Format confirmed per R8 (Sandeep, 2026-04-29): digit-only serial [A-Z]\d{7}.

This object is stateless and thread-safe.

Samples

Passport.validate("A1234567") // ValidationResult.Valid
Passport.format("a1234567") // "A1234567"
Passport.mask("A1234567") // "XXXX4567"

Functions

Link copied to clipboard
fun format(value: String): String

Formats a Passport number to canonical form: 8-character uppercase, no separators.

Link copied to clipboard
fun isValid(value: String): Boolean

Returns true if validate returns ValidationResult.Valid.

Link copied to clipboard
fun mask(value: String, visibleStart: Int = 0, visibleEnd: Int = 4, maskChar: Char = 'X'): String

Masks a Passport number for PII-safe display.

Link copied to clipboard

Validates an Indian Passport number.