Passport Number Validation Function Documentation

The validatePassportNumber function is used to validate passport numbers. It returns an object with two properties: 'isValid' (boolean) and 'country' (string). The 'isValid' property will be true if the passport number matches the supported formats, and 'country' property will indicate the country associated with the passport number. If the passport number does not match any supported format, 'isValid' will be false, and 'country' will be null.

Function Signature

function validatePassportNumber(
		passportNumber: string
): { isValid: boolean, country: string | null };

Parameters

Examples

const result1 = validatePassportNumber('A1234567');
console.log(result1);
// Output: { isValid: true, country: 'United States' }

const result2 = validatePassportNumber('123456789');
console.log(result2);
// Output: { isValid: false, country: null }

Supported Passport Formats