Opened 13 years ago

Closed 12 years ago

#17355 closed Bug (invalid)

Perform proper NANP validation in US/CA localflavor phone number

Reported by: Dan McGee Owned by: nobody
Component: contrib.localflavor Version: 1.3
Severity: Normal Keywords: areacode, nanp, localflavorsplit
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

Patch attached.

http://en.wikipedia.org/wiki/North_American_Numbering_Plan

Long story short:

1-NPA-NXX-XXXX

  • NPA: 3 digits, 1st is [2-9], 2nd/3rd are [0-9]. 2 and 3 cannot both be '1'.
  • NXX: 3 digits, 1st is [2-9], 2nd/3rd are [0-9]. 2 and 3 cannot both be '1'.
  • XXXX: 4 digits, no restrictions.

Former code allowed any digit in all locations, meaning the following bogus phone numbers (now in tests as invalid) were accepted:

'023-234-5678'
'123-234-5678'
'323-134-5678'
'312-034-5678'
'311-134-5678'
'312-211-5678'

Attachments (1)

nanp-proper-validation.patch (4.9 KB ) - added by Dan McGee 13 years ago.

Download all attachments as: .zip

Change History (4)

by Dan McGee, 13 years ago

comment:1 by Dan McGee, 13 years ago

Note that this will conflict slightly with #7463, which also makes the US and CA phone number validators stray from each other, which is likely not a good idea.

comment:2 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedAccepted

comment:3 by Aymeric Augustin, 12 years ago

Keywords: localflavorsplit added
Resolution: invalid
Status: newclosed

django.contrib.localflavor is now deprecated — see https://docs.djangoproject.com/en/dev/ref/contrib/localflavor/

A repository was created for each localflavor at https://github.com/django/django-localflavor-? (Replace with the country code.)

If you're still interested in this ticket, could you create a pull request on that repository?

Sorry for not resolving this issue earlier, and thanks for your input!

Note: See TracTickets for help on using tickets.
Back to Top