Skip to content

Passport

import { validatePassport } from 'pakdatakit/passport'

Checks that a passport number has the common shape: two letters followed by seven digits, such as AB1234567. Case, surrounding spaces, and spaces or dashes between the letters and digits are ignored.

validatePassport() Common shape

import { validatePassport } from 'pakdatakit';
validatePassport('AB1234567');
// → true
validatePassport('ab 1234567');
// → true
validatePassport('A12345678');
// → false
function validatePassport(passport: string): boolean;

Parameters. passport: the passport number. Case, surrounding spaces and spaces or dashes between the letters and digits are ignored.

Returns true when the number is two letters followed by seven digits; otherwise false.

Caveats. Two letters and seven digits is the number format given for the 2013 ordinary passport in the EU’s PRADO register, and it fits the 9-character document-number field of ICAO Doc 9303. The letters’ meaning is not documented and is not checked. The MRZ check digit is not part of the number.

Related: CNIC.