isPhoneNumber
Using this method, you can check whether the received input is a phone number or not
Params
isPhoneNumber(str,regions = []);
- str → str Write the string you want to check whether it is a phone number or not in this parameter and pass it to the function
- regions → An array of regions where the phone number must be in the form of one of these regions to return true, if this parameter is not given, all possible regions will be checked by default.
regions
The text format of the region string is exactly the same as the express-validator package
Returns
true | false
- Boolean → If the input string is a PhoneNumber, it returns true and if the input string is not a PhoneNumber, it returns false.
Usage
isPhoneNumber("09121234567"); //true
isPhoneNumber("+989121234567"); //true
isPhoneNumber("9121234567",['fa-IR']); //true
isPhoneNumber("09121234567",['en-US']); //false
isPhoneNumber("09121234567",['en-US','fa-IR']); //true
isPhoneNumber("9121234567"); //true
isPhoneNumber("+989121234567"); //true