lanka-validations - v2.1.0
    Preparing search index...

    Function parsePassport

    • Parses a Sri Lankan passport number. Standard MRP: 1 letter (N, M, L, D, O) + 7 digits (e.g. N1234567) E-Passport: 1-2 letters + 7-8 digits (e.g. P1234567, PA1234567)

      Parameters

      • rawPassport: unknown

        Passport number. Strings and finite numbers are accepted; other types return a failure without throwing.

      Returns PassportInfo | null

      Series prefix, digits, and inferred type, or null if the format is invalid.

      parsePassport('N1234567')?.type; // 'ordinary'
      parsePassport('D1234567')?.type; // 'diplomatic'