2015-11-19 23:47:25 +00:00
|
|
|
CREATE EXTENSION IF NOT EXISTS pg_libphonenumber;
|
|
|
|
--Test phone number parsing
|
2019-07-31 06:06:24 +00:00
|
|
|
select parse_packed_phone_number('555-555-5555', 'US');
|
|
|
|
parse_packed_phone_number
|
|
|
|
---------------------------
|
2015-11-19 23:47:25 +00:00
|
|
|
+1 555-555-5555
|
|
|
|
(1 row)
|
|
|
|
|
|
|
|
--These two should produce errors because the number is too long.
|
|
|
|
--Produces an error in pg-libphonenumber's code
|
2019-07-31 06:06:24 +00:00
|
|
|
select parse_packed_phone_number('555-555-5555555555', 'US');
|
2015-11-19 23:47:25 +00:00
|
|
|
ERROR: phone number '+1 5555555555555555' is too long
|
|
|
|
DETAIL: National number is too long
|
|
|
|
--Produces an error from libphonenumber
|
2019-07-31 06:06:24 +00:00
|
|
|
select parse_packed_phone_number('555-555-55555555555', 'US');
|
2015-11-19 23:47:25 +00:00
|
|
|
ERROR: unable to parse '555-555-55555555555' as a phone number
|
|
|
|
DETAIL: National number is too long
|
2017-03-13 21:32:50 +00:00
|
|
|
-- Do we get correct country codes?
|
|
|
|
-- TODO: expand.
|
2019-07-31 06:06:24 +00:00
|
|
|
select phone_number_country_code(parse_packed_phone_number('+1-555-555-5555', 'USA'));
|
2017-03-13 21:32:50 +00:00
|
|
|
phone_number_country_code
|
|
|
|
---------------------------
|
|
|
|
1
|
|
|
|
(1 row)
|
|
|
|
|