a!isPhoneNumber( phoneNumber, countryCode )
Returns true if the phoneNumber parameter contains a valid phone number, otherwise returns false. A phone number is considered valid if its area code is valid, the length is appropriate based upon the value of the countryCode parameter, and the number after the area code is not all zeroes. This function supports countries and area codes for international numbers.
Keyword | Type | Description |
---|---|---|
|
Text |
A text value representing a phone number. Dashes, parentheses, periods, and blank spaces are allowed as separators. This parameter is required. |
|
Text Array |
One or more country codes used to validate the provided phone number. Country codes are represented as a two-letter ISO alpha-2 code. For example, |
Boolean
A phone number is considered valid if:
Note: A valid phone number does not mean it is connected.
However, an invalid phone number can still be dialed. For example, the phone number 1800-MICROSOFT
is invalid because it is too long, but a user could dial this number since the extra digits will be ignored.
The countryCode parameter can include one or more country codes. If you provide multiple country codes, the function will return true when it matches one of the provided country codes. See a list of supported country codes below.
If the phone number does not match any of the provided country codes, the function will return false.
If no countryCode is provided, but the phone number contains an international code (+[country code]
), then the function will use the international code to determine if the provided phone number is valid.
For example, let's say you provide the phone number +34 913 30 28 00
without providing a countryCode parameter. Since +34
is the international code for Spain, the function will return true if the provided phone number is a Spain phone number.
Copy and paste these examples into an Appian Expression Editor to test out this function.
The countryCode parameter is optional if an international code (+<international code here>
) is provided as part of the phone number.
For example, the example below does not need the countryCode parameter since the international code (+52
) is part of the provided phone number.
1
2
3
a!isPhoneNumber(
phoneNumber: "+52 55 5487 3100",
)
Returns true
However, if you tried to use the following example, the function would return false
because there is no international code in the provided phone number, and no countryCode parameter.
1
2
3
a!isPhoneNumber(
phoneNumber: "55 5487 3100",
)
Returns false
1
2
3
4
5
6
a!isPhoneNumber(
/* This is a valid Cancun mobile phone number */
phoneNumber: "1-998-185-3133",
/* United States country code */
countryCode: "US",
)
Returns false
The countryCode parameter can accept an array of country codes. You may want to add a list of country codes if your application is used across multiple countries so you can validate different phone numbers accordingly.
In the example below, there are two country codes: Mexico and United States. Since this is phone number in Mexico, the function will ignore the first country code (United States) and validate as a phone number in Mexico.
1
2
3
4
5
6
a!isPhoneNumber(
/* This is a valid Cancun mobile phone number */
phoneNumber: "1-998-185-3133",
/* Mexico and United States country codes */
countryCode: {"US", "MX"}
)
Returns true
The following example uses the a!isPhoneNumber()
and a!formatPhoneNumber() functions to validate and format a user-provided phone number, which could be a phone number in the United States, Great Britain, or Germany.
Copy and paste this example into an Appian Interface to test out this function.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
a!localVariables(
local!phoneNumber,
local!isNumberValid,
a!textField(
label: "Phone Number",
labelPosition: "ABOVE",
instructions: "Enter a phone number",
value: local!phoneNumber,
saveInto: {
local!phoneNumber,
a!save(
local!isNumberValid,
a!isPhoneNumber(
phoneNumber: local!phoneNumber,
countryCode: {"US", "GB", "DE"}
)
),
if(
local!isNumberValid,
a!save(
local!phoneNumber,
a!formatPhoneNumber(
phoneNumber: local!phoneNumber,
countryCode: {"US", "GB", "DE"},
outputFormat: "INTERNATIONAL",
)
),
{}
)
},
refreshAfter: "UNFOCUS",
validations: if(
local!isNumberValid,
"",
"Please enter a valid phone number."
),
inputPurpose: "PHONE_NUMBER",
)
)
Returns
The following table lists all ISO alpha-2 codes supported by the a!isPhoneNumber()
function:
Code | Country Name |
AC
|
Ascension Island |
AD
|
Andorra |
AE
|
United Arab Emirates |
AF
|
Afghanistan |
AG
|
Antigua and Barbuda |
>AI
|
Anguilla |
AL
|
Albania |
AM
|
Armenia |
AO
|
Angola |
AR
|
Argentina |
AS
|
American Samoa |
AT
|
Austria |
AU
|
Australia |
>AW
|
Aruba |
AX
|
Aland Islands |
AZ
|
Azerbaijan |
BA
|
Bosnia and Herzegovina |
BB
|
Barbados |
BD
|
Bangladesh |
BE
|
Belgium |
BF
|
Burkina Faso |
BG
|
Bulgaria |
BH
|
Bahrain |
BI
|
Burundi |
BJ
|
Benin |
BL
|
Saint Barthélemy |
BM
|
Bermuda |
BN
|
Brunei Darussalam |
BO
|
Bolivia (Plurinational State of) |
BQ
|
Bonaire, Sint Eustatius and Saba |
BR
|
Brazil |
BS
|
Bahamas |
BT
|
Bhutan |
BW
|
Botswana |
BY
|
Belarus |
BZ
|
Belize |
CA
|
Canada |
CC
|
Cocos (Keeling) Islands |
CD
|
Congo, Democratic Republic of the |
CF
|
Central African Republic |
CG
|
Congo |
CH
|
Switzerland |
CI
|
Côte d'Ivoire |
CK
|
Cook Islands |
CL
|
Chile |
CM
|
Cameroon |
CN
|
China |
CO
|
Colombia |
CR
|
Costa Rica |
CU
|
Cuba |
CV
|
Cabo Verde |
CW
|
Curaçao |
CX
|
Christmas Island |
CY
|
Cyprus |
CZ
|
Czechia |
DE
|
Germany |
DJ
|
Djibouti |
DK
|
Denmark |
DM
|
Dominica |
DO
|
Dominican Republic |
DZ
|
Algeria |
EC
|
Ecuador |
EE
|
Estonia |
EG
|
Egypt |
EH
|
Western Sahara |
ER
|
Eritrea |
ES
|
Spain |
ET
|
Ethiopia |
FI
|
Finland |
FJ
|
Fiji |
FK
|
Falkland Islands (Malvinas) |
FM
|
Micronesia (Federated States of) |
FO
|
Faroe Islands |
FR
|
France |
GA
|
Gabon |
GB
|
United Kingdom of Great Britain and Northern Ireland |
GD
|
Grenada |
GE
|
Georgia |
GF
|
French Guiana |
GG
|
Guernsey |
GH
|
Ghana |
GI
|
Gibraltar |
GL
|
Greenland |
GM
|
Gambia |
GN
|
Guinea |
GP
|
Guadeloupe |
GQ
|
Equatorial Guinea |
GR
|
Greece |
GT
|
Guatemala |
GU
|
Guam |
GW
|
Guinea-Bissau |
GY
|
Guyana |
HK
|
Hong Kong |
HN
|
Honduras |
HR
|
Croatia |
HT
|
Haiti |
HU
|
Hungary |
ID
|
Indonesia |
IE
|
Ireland |
IL
|
Israel |
IM
|
Isle of Man |
IN
|
India |
IO
|
British Indian Ocean Territory |
IQ
|
Iraq |
IR
|
Iran (Islamic Republic of) |
IS
|
Iceland |
IT
|
Italy |
JE
|
Jersey |
JM
|
Jamaica |
JO
|
Jordan |
JP
|
Japan |
KE
|
Kenya |
KG
|
Kyrgyzstan |
KH
|
Cambodia |
KI
|
Kiribati |
KM
|
Comoros |
KN
|
Saint Kitts and Nevis |
KP
|
Korea (Democratic People's Republic of) |
KR
|
Korea, Republic of |
KW
|
Kuwait |
KY
|
Cayman Islands |
KZ
|
Kazakhstan |
LA
|
Lao People's Democratic Republic |
LB
|
Lebanon |
LC
|
Saint Lucia |
LI
|
Liechtenstein |
LK
|
Sri Lanka |
LR
|
Liberia |
LS
|
Lesotho |
LT
|
Lithuania |
LU
|
Luxembourg |
LV
|
Latvia |
LY
|
Libya |
MA
|
Morocco |
MC
|
Monaco |
MD
|
Moldova, Republic of |
ME
|
Montenegro |
MF
|
Saint Martin (French part) |
MG
|
Madagascar |
MH
|
Marshall Islands |
MK
|
North Macedonia |
ML
|
Mali |
MM
|
Myanmar |
MN
|
Mongolia |
MO
|
Macao |
MP
|
Northern Mariana Islands |
MQ
|
Martinique |
MR
|
Mauritania |
MS
|
Montserrat |
MT
|
Malta |
MU
|
Mauritius |
MV
|
Maldives |
MW
|
Malawi |
MX
|
Mexico |
MY
|
Malaysia |
MZ
|
Mozambique |
NA
|
Namibia |
NC
|
New Caledonia |
NE
|
Niger |
NF
|
Norfolk Island |
NG
|
Nigeria |
NI
|
Nicaragua |
NL
|
Netherlands, Kingdom of the |
NO
|
Norway |
NP
|
Nepal |
NR
|
Nauru |
NU
|
Niue |
NZ
|
New Zealand |
OM
|
Oman |
PA
|
Panama |
PE
|
Peru |
PF
|
French Polynesia |
PG
|
Papua New Guinea |
PH
|
Philippines |
PK
|
Pakistan |
PL
|
Poland |
PM
|
Saint Pierre and Miquelon |
PR
|
Puerto Rico |
PS
|
Palestine, State of |
PT
|
Portugal |
PW
|
Palau |
PY
|
Paraguay |
QA
|
Qatar |
RE
|
Réunion |
RO
|
Romania |
RS
|
Serbia |
RU
|
Russian Federation |
RW
|
Rwanda |
SA
|
Saudi Arabia |
SB
|
Solomon Islands |
SC
|
Seychelles |
SD
|
Sudan |
SE
|
Sweden |
SG
|
Singapore |
SH
|
Saint Helena, Ascension and Tristan da Cunha |
SI
|
Slovenia |
SJ
|
Svalbard and Jan Mayen |
SK
|
Slovakia |
SL
|
Sierra Leone |
SM
|
San Marino |
SN
|
Senegal |
SO
|
Somalia |
SR
|
Suriname |
SS
|
South Sudan |
ST
|
Sao Tome and Principe |
SV
|
El Salvador |
SX
|
Sint Maarten (Dutch part) |
SY
|
Syrian Arab Republic |
SZ
|
Eswatini |
TA
|
Tristan da Cunha |
TC
|
Turks and Caicos Islands |
TD
|
Chad |
TG
|
Togo |
TH
|
Thailand |
TJ
|
Tajikistan |
TK
|
Tokelau |
TL
|
Timor-Leste |
TM
|
Turkmenistan |
TN
|
Tunisia |
TO
|
Tonga |
TR
|
Turkiye |
TT
|
Trinidad and Tobago |
TV
|
Tuvalu |
TW
|
Taiwan, Province of China |
TZ
|
Tanzania, United Republic of |
UA
|
Ukraine |
UG
|
Uganda |
US
|
United States of America |
UY
|
Uruguay |
UZ
|
Uzbekistan |
VA
|
Holy See |
VC
|
Saint Vincent and the Grenadines |
VE
|
Venezuela (Bolivarian Republic of) |
VG
|
Virgin Islands (British) |
VI
|
Virgin Islands (U.S.) |
VN
|
Viet Nam |
VU
|
Vanuatu |
WF
|
Wallis and Futuna |
WS
|
Samoa |
XK
|
Temporary for Kosovo |
YE
|
Yemen |
YT
|
Mayotte |
ZA
|
South Africa |
ZM
|
Zambia |
ZW
|
Zimbabwe |
Feature | Compatibility | Note |
---|---|---|
Portals | Compatible | |
Offline Mobile | Compatible | |
Sync-Time Custom Record Fields | Compatible | Can be used to create a custom record field that only evaluates at sync time. |
Real-Time Custom Record Fields | Incompatible | Custom record fields that evaluate in real time must be configured using one or more Custom Field functions. |
Process Reports | Incompatible | Cannot be used to configure a process report. |
Process Events | Incompatible | Cannot be used to configure a process event node, such as a start event or timer event. |
a!isPhoneNumber() Function