From 121129f5b9d7b102d8bbaab8c32832e7a274e231 Mon Sep 17 00:00:00 2001 From: Ben Konrath Date: Fri, 7 May 2021 15:11:27 +0200 Subject: [PATCH] Updated IBAN validation for latest changes (#436) --- docs/changelog.rst | 4 +++- localflavor/generic/validators.py | 7 ++++--- tests/test_generic/tests.py | 8 ++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index 07f35202c..b18c6cfbd 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -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) @@ -25,6 +25,8 @@ Modifications to existing flavors: (`gh-424 `_ `gh-428 `_). - Added new region for CL (`gh-432 `_, `gh-433 `_). +- Updated IBAN validation for changes in IBAN Registry release 89, March 2021 + (`gh-436 `_). Other changes: diff --git a/localflavor/generic/validators.py b/localflavor/generic/validators.py index 4235f375c..bb552ccbb 100644 --- a/localflavor/generic/validators.py +++ b/localflavor/generic/validators.py @@ -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: # @@ -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 @@ -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 @@ -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 diff --git a/tests/test_generic/tests.py b/tests/test_generic/tests.py index ff1ef0925..2489a0d6e 100644 --- a/tests/test_generic/tests.py +++ b/tests/test_generic/tests.py @@ -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) @@ -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):