/** * Custom phone number validation and formatting utilities * Replaces google-libphonenumber dependency with self-contained implementation */ /** * Phone number parsing result */ export interface PhoneNumber { /** Country calling code (e.g., '1' for US/CA, '44' for UK, '61' for AU) */ countryCode: string; /** National number without country code */ nationalNumber: string; /** Whether the phone number is valid */ isValid: boolean; /** Phone number in E.164 format (e.g., '+14155552671') */ e164Format?: string; } /** * Get country calling code for a given country code * * @param countryCode - ISO 3166-1 alpha-2 country code (e.g., 'US', 'GB', 'AU') * @returns Country calling code (e.g., '1', '44', '61') or undefined if not found */ export declare function getCountryCallingCode(countryCode: string): string | undefined; /** * Parse a phone number and extract its components * * @param phoneNumber - Phone number to parse (with or without country code) * @param defaultCountryCode - Default country code to use if not in international format (e.g., 'US', 'AU') * @returns Parsed phone number components * * @example * parsePhoneNumber('+14155552671') // { countryCode: '1', nationalNumber: '4155552671', isValid: true, e164Format: '+14155552671' } * parsePhoneNumber('4155552671', 'US') // { countryCode: '1', nationalNumber: '4155552671', isValid: true, e164Format: '+14155552671' } * parsePhoneNumber('0437536808', 'AU') // { countryCode: '61', nationalNumber: '437536808', isValid: true, e164Format: '+61437536808' } */ export declare function parsePhoneNumber(phoneNumber: string, defaultCountryCode?: string): PhoneNumber; /** * Format a phone number to E.164 format (+[country code][national number]) * * @param phoneNumber - Phone number to format * @param defaultCountryCode - Default country code if not in international format * @returns E.164 formatted phone number or null if invalid * * @example * formatToE164('+1 415 555 2671') // '+14155552671' * formatToE164('415-555-2671', 'US') // '+14155552671' * formatToE164('0437 536 808', 'AU') // '+61437536808' */ export declare function formatToE164(phoneNumber: string, defaultCountryCode?: string): string | null; /** * Check if a phone number is valid * * @param phoneNumber - Phone number to validate * @returns true if the phone number is valid * * @example * isValidPhoneNumber('+14155552671') // true * isValidPhoneNumber('123') // false * isValidPhoneNumber('') // false */ export declare function isValidPhoneNumber(phoneNumber: string): boolean; /** * Format a phone number in international format for display * E.g., +1 415 555 2671 * * @param phoneNumber - Phone number to format * @returns Formatted phone number for display * * @example * formatInternational('+14155552671') // '+1 4155552671' * formatInternational('+61437536808') // '+61 437536808' */ export declare function formatInternational(phoneNumber: string): string; /** * Parse phone number and validate it * Mimics google-libphonenumber's parseAndKeepRawInput behavior * * @param phoneNumber - Phone number to parse * @param defaultCountryCode - Default country code * @returns Parsed phone number object */ export declare function parseAndKeepRawInput(phoneNumber: string, defaultCountryCode?: string): PhoneNumber; /** * Check if a parsed phone number is valid * Mimics google-libphonenumber's isValidNumber behavior * * @param phoneNumber - Parsed phone number object * @returns true if valid */ export declare function isValidNumber(phoneNumber: PhoneNumber): boolean; /** * Format a parsed phone number to E.164 * Mimics google-libphonenumber's format behavior * * @param phoneNumber - Parsed phone number object * @returns E.164 formatted phone number */ export declare function format(phoneNumber: PhoneNumber): string;