Skip to content

Instantly share code, notes, and snippets.

@leods92
Last active December 22, 2015 02:48
Show Gist options
  • Save leods92/6405525 to your computer and use it in GitHub Desktop.
Save leods92/6405525 to your computer and use it in GitHub Desktop.
Validação de números celulares no Brasil (válido em 1º de setembro de 2013).
# first 2 digits represent dialing code
# dialing codes in Brazil don't start with 0
#
# the following represent the phone
# must have 8 digits
# might have 9 if dialing code is 11, 12, 13, 14, 15, 16, 17, 18 or 19
# http://g1.globo.com/sao-paulo/noticia/2013/08/nono-digito-comeca-valer-para-telefones-celulares-do-interior-paulista.html
# first digit must start with 7, 8 or 9
# might start with 5 as well if dialing code is 11
#
MOBILE_REGEXP = /\A(11(5|[7-9])\d{7,8}|1[2-9][7-9]\d{7,8}|[2-9]\d[7-9]\d{7})\z/
@leods92
Copy link
Author

leods92 commented Sep 1, 2013

E para quem procura um validator completo para Rails que também avalia números fixos: https://gist.github.com/leods92/6405552

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment