Created
December 25, 2021 02:03
-
-
Save brunomarks7/6c13c10e1b2654ee3e9bd921b56e65a6 to your computer and use it in GitHub Desktop.
Validate brazilian phone / cellphone by national patterns (regex)
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
const checkPhonepattern = phone => { | |
// checa se o telefone é fixo com começo entre 2 e 5 | |
// ou celular com 9 dig e começo entre 6 e 9 | |
if ( (/^(?:(55\d{2})|\d{2})[2-5]\d{7}$/.test(phone)) || (/^(?:(55\d{2})|\d{2})[6-9]\d{8}$/.test(phone))) { | |
return true; | |
}else { | |
return false; | |
} | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment