/** * Guatemalan Passport Number (Pasaporte guatemalteco). * * Format: Guatemalan passport number is nine digits, no letters, per the ICAO standard adopted by the Guatemalan Migration Institute (IGM) in 2024 (previously 15 digits). * * Source * https://www.copaair.com/assets/Update-in-the-numbering-of-Guatemalan-passports.pdf * https://danskebank.fi/-/media/pdf/danske-bank/fi/en/national-identifier-list-final.pdf * https://en.wikipedia.org/wiki/Guatemalan_passport * * PERSON */ import * as exceptions from '../exceptions'; import { strings } from '../util'; import { Validator, ValidateReturn } from '../types'; function clean(input: string): ReturnType { return strings.cleanUnicode(input, ' -./,'); } const idRegexp = /^\d{9}$/; const impl: Validator = { name: 'Guatemalan Passport Number', localName: 'Pasaporte guatemalteco', abbreviation: 'Passport', examples: ['123456789'], formats: ['nnnnnnnnn'], compact(input: string): string { const [value, err] = clean(input); if (err) { throw err; } return value; }, format(input: string): string { const [value] = clean(input); return value; }, validate(input: string): ValidateReturn { const [value, error] = clean(input); if (error) { return { isValid: false, error }; } if (value.length !== 9) { return { isValid: false, error: new exceptions.InvalidLength() }; } const match = value.match(idRegexp); if (!match) { return { isValid: false, error: new exceptions.InvalidFormat() }; } return { isValid: true, compact: value, isIndividual: true, isCompany: false, }; }, }; export const { name, localName, abbreviation, examples, formats, validate, format, compact, } = impl;