Last active
October 27, 2020 16:00
-
-
Save kevinchisholm/459c17d7ca6f79b1bbb4ef7c00e53f1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validatePhoneForE164(phoneNumber) { | |
const regEx = /^\+[1-9]\d{10,14}$/; | |
return regEx.test(phoneNumber); | |
}; | |
validatePhoneForE164('+12125551212'); // true | |
validatePhoneForE164('12125551212'); // false | |
validatePhoneForE164('2125551212'); // false | |
validatePhoneForE164('+1-212-555-1212'); // false | |
validatePhoneForE164('+1 212 555 1212'); // false | |
validatePhoneForE164('+1 (212) 555-1212'); // false |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment