Canada localflavor: postal code validation too lax
|Reported by:||paulschreiber||Owned by:||kmtracey|
|Severity:||Keywords:||canada postal code|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
In the Canada localflavor package, postal code validation is too lax. As of Django 1.1.1, we have this:
def __init__(self, *args, **kwargs): super(CAPostalCodeField, self).__init__(r'^[ABCEGHJKLMNPRSTVXYZ]\d[A-Z] \d[A-Z]\d$',
However, no postal code includes the letters D, F, I, O, Q, or U.
The letters W and Z are used, but are not currently used as the first letter.
I can't find this on the Canada Post web site, but it's documented in many places.
You want something like this:
def __init__(self, *args, **kwargs): super(CAPostalCodeField, self).__init__(r'^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] \d[ABCEGHJKLMNPRSTVWXYZ]\d$',
Change History (8)
comment:1 Changed 6 years ago by agabel
- Needs documentation unset
- Needs tests unset
- Patch needs improvement unset