Parses and inspects a Sri Lankan phone number (mobile, landline, or short code). Returns PhoneInfo if valid, or null if invalid.
Phone number in any common format. Strings and finite numbers are accepted; other types return a failure without throwing.
Number type, formats, prefix, area, and originally allocated operator, or null if invalid.
null
parsePhone('0771234567')?.type; // 'mobile'parsePhone('0771234567')?.international; // '+94 77 123 4567'parsePhone('0112345678')?.areaName; // 'Colombo' Copy
parsePhone('0771234567')?.type; // 'mobile'parsePhone('0771234567')?.international; // '+94 77 123 4567'parsePhone('0112345678')?.areaName; // 'Colombo'
Parses and inspects a Sri Lankan phone number (mobile, landline, or short code). Returns PhoneInfo if valid, or null if invalid.