Forked from kevinchisholm/validate-phone-for-e164.js
Created
October 27, 2020 16:00
-
-
Save jayvi/35a135bea869255d9109f9bce7c5d800 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