bigfunctions > phone_number_info
phone_number_info¶
Signature
phone_number_info(phone_number, options)
Description
Get phone_number
info
such as:
country
,isValid
,- etc
using libphonenumber-js library.
Argument options
can be null
or must be a json with the following keys:
defaultCountry
, defaultCallingCode
and extract
as described in the
library documentation.
Examples
1. Get info about an international phone_number
(starting with +
)
select bigfunctions.eu.phone_number_info('+33123456789', null)
select bigfunctions.us.phone_number_info('+33123456789', null)
select bigfunctions.europe_west1.phone_number_info('+33123456789', null)
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| info |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"isPossible": true,
"isValid": true,
"parseError": null,
"country": "FR",
"countryCallingCode": "33",
"formattedInternational": "+33 1 23 45 67 89",
"formattedNational": "01 23 45 67 89",
"isNonGeographic": false,
"nationalNumber": "123456789",
"number": "+33123456789",
"possibleCountries": ["FR"],
"type": "FIXED_LINE",
"uri": "tel:+33123456789"
}
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
2. Get info about a national phone_number
select bigfunctions.eu.phone_number_info('0123456789', json '{"defaultCountry": "FR"}')
select bigfunctions.us.phone_number_info('0123456789', json '{"defaultCountry": "FR"}')
select bigfunctions.europe_west1.phone_number_info('0123456789', json '{"defaultCountry": "FR"}')
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| info |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"isPossible": true,
"isValid": true,
"parseError": null,
"country": "FR",
"countryCallingCode": "33",
"formattedInternational": "+33 1 23 45 67 89",
"formattedNational": "01 23 45 67 89",
"isNonGeographic": false,
"nationalNumber": "123456789",
"number": "+33123456789",
"possibleCountries": ["FR"],
"type": "FIXED_LINE",
"uri": "tel:+33123456789"
}
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
3. If no phone number is found in phone_number
argument, a reason in given in parseError
select bigfunctions.eu.phone_number_info('Hello!', null)
select bigfunctions.us.phone_number_info('Hello!', null)
select bigfunctions.europe_west1.phone_number_info('Hello!', null)
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| info |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"isPossible": false,
"isValid": false,
"parseError": "NOT_A_NUMBER",
"country": null,
"countryCallingCode": null,
"formattedInternational": null,
"formattedNational": null,
"isNonGeographic": null,
"nationalNumber": null,
"number": null,
"possibleCountries": null,
"type": null,
"uri": null,
}
|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
4. By default, if the given phone_number
text contains a phone number among other text, it will be extracted.
select bigfunctions.eu.phone_number_info('Hello +33123456789 !', null)
select bigfunctions.us.phone_number_info('Hello +33123456789 !', null)
select bigfunctions.europe_west1.phone_number_info('Hello +33123456789 !', null)
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| info |
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"isPossible": true,
"isValid": true,
"parseError": null,
"country": "FR",
"countryCallingCode": "33",
"formattedInternational": "+33 1 23 45 67 89",
"formattedNational": "01 23 45 67 89",
"isNonGeographic": false,
"nationalNumber": "123456789",
"number": "+33123456789",
"possibleCountries": ["FR"],
"type": "FIXED_LINE",
"uri": "tel:+33123456789"
}
|
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
5. To consider that phone_number
cannot have additional text use extract: false
as option
select bigfunctions.eu.phone_number_info('Hello +33123456789 !', json '{"extract": false}')
select bigfunctions.us.phone_number_info('Hello +33123456789 !', json '{"extract": false}')
select bigfunctions.europe_west1.phone_number_info('Hello +33123456789 !', json '{"extract": false}')
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| info |
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| {
"isPossible": false,
"isValid": false,
"parseError": "NOT_A_NUMBER",
"country": null,
"countryCallingCode": null,
"formattedInternational": null,
"formattedNational": null,
"isNonGeographic": null,
"nationalNumber": null,
"number": null,
"possibleCountries": null,
"type": null,
"uri": null,
}
|
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+