Skip to content

Commit

Permalink
Updated IBAN validation for latest changes (#436)
Browse files Browse the repository at this point in the history
  • Loading branch information
benkonrath authored May 7, 2021
1 parent e8d021e commit 121129f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
4 changes: 3 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Modifications to existing flavors:

- Fix `FRNationalIdentificationNumber` validation for people born overseas
- Updated Indian states and union territories names and code as per iso 3166 (https://www.iso.org/obp/ui/#iso:code:3166:IN)
- Breaking data changes: The key for Chattisgarh has been changed from CG to CT, the key for Uttarakhand has been changed from UA to UT,
- Breaking data changes: The key for Chattisgarh has been changed from CG to CT, the key for Uttarakhand has been changed from UA to UT,
and the keys DD (Dadra and Nagar Haveli) and DN (Daman and Diu) have been removed and combined into DH (Dadra and Nagar Haveli and Daman and Diu)
Previous State Jammu and Kashmir (JK) is now under Union Territories, Ladakh (LA) is the new addition in the Union Territories.
Few modificication in the States and Union Territories names: Orissa (OR) is now Odisha (OR), Pondicherry (PY) is now Puducherry (PY)
Expand All @@ -25,6 +25,8 @@ Modifications to existing flavors:
(`gh-424 <https://github.com/django/django-localflavor/issues/424>`_
`gh-428 <https://github.com/django/django-localflavor/pull/428>`_).
- Added new region for CL (`gh-432 <https://github.com/django/django-localflavor/issues/432>`_, `gh-433 <https://github.com/django/django-localflavor/pull/433>`_).
- Updated IBAN validation for changes in IBAN Registry release 89, March 2021
(`gh-436 <https://github.com/django/django-localflavor/issues/436>`_).

Other changes:

Expand Down
7 changes: 4 additions & 3 deletions localflavor/generic/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#
# https://www.swift.com/standards/data-standards/iban
#
# The IBAN_COUNTRY_CODE_LENGTH dictionary has been updated version 78 of the IBAN Registry document which was published
# in August 2017.
# The IBAN_COUNTRY_CODE_LENGTH dictionary has been updated version 89 of the IBAN Registry document which was published
# in March 2021.
#
# Other Resources:
#
Expand Down Expand Up @@ -44,6 +44,7 @@
'DK': 18, # Denmark
'DO': 28, # Dominican Republic
'EE': 20, # Estonia
'EG': 29, # Egypt
'ES': 24, # Spain
'FI': 18, # Finland
'FO': 18, # Faroe Islands
Expand Down Expand Up @@ -74,6 +75,7 @@
'LT': 20, # Lithuania
'LU': 20, # Luxembourg
'LV': 21, # Latvia
'LY': 25, # Libya
'MC': 27, # Monaco
'MD': 24, # Moldova
'ME': 22, # Montenegro
Expand Down Expand Up @@ -121,7 +123,6 @@
'CM': 27, # Cameroon
'CV': 25, # Cape Verde
'DZ': 24, # Algeria
'EG': 27, # Egypt
'GA': 27, # Gabon
'IR': 26, # Iran
'MG': 27, # Madagascar
Expand Down
8 changes: 4 additions & 4 deletions tests/test_generic/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def test_iban_fields(self):
'Ensure this value has at most 34 characters (it has 35).'],

# This IBAN should only be valid only if the Nordea extensions are turned on.
'EG1100006001880800100014553': ['EG is not a valid country code for IBAN.'],
'EG11 0000 6001 8808 0010 0014 553': ['EG is not a valid country code for IBAN.']
'BJ11B00610100400271101192591': ['BJ is not a valid country code for IBAN.'],
'BJ11 B006 1010 0400 2711 0119 2591': ['BJ is not a valid country code for IBAN.']
}

self.assertFieldOutput(IBANFormField, valid=valid, invalid=invalid)
Expand All @@ -209,10 +209,10 @@ def test_nordea_extensions(self):
"""Test a valid IBAN in the Nordea extensions."""
iban_validator = IBANValidator(use_nordea_extensions=True)
# Run the validator to ensure there are no ValidationErrors raised.
iban_validator('Eg1100006001880800100014553')
iban_validator('Bj11B00610100400271101192591')

def test_use_nordea_extensions_formfield(self):
form = UseNordeaExtensionsForm({'iban': 'EG1100006001880800100014553'})
form = UseNordeaExtensionsForm({'iban': 'BJ11B00610100400271101192591'})
self.assertFalse(form.errors)

def test_include_countries_formfield(self):
Expand Down

0 comments on commit 121129f

Please sign in to comment.