Generate valid Spanish CCC control digits in es_ES IBAN/BBAN#2419
Open
eeshsaxena wants to merge 1 commit into
Open
Generate valid Spanish CCC control digits in es_ES IBAN/BBAN#2419eeshsaxena wants to merge 1 commit into
eeshsaxena wants to merge 1 commit into
Conversation
Faker('es_ES').iban() filled the two national control digits of the CCC
randomly, so the IBANs passed the ISO 13616 mod-97 check but failed
country-level validation. Override bban() to compute both control digits
from the entity/office code and account number, matching the approach
used for Belgium (nl_BE).
Fixes joke2k#2398
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fixes #2398.
Faker('es_ES').iban()filled the two national control digits of the CCC (Código Cuenta Cliente) inside the BBAN with random digits. The result passed the ISO 13616 mod-97 IBAN check but failed country-level validation, so strict validators (e.g.python-stdnum) rejected ~99% of the generated IBANs.This overrides
bban()for thees_ESbank provider to compute both control digits — the first from the entity/office code (padded to ten digits with two leading zeros), the second from the account number — using the standard CCC weight table(1, 2, 4, 8, 5, 10, 9, 7, 3, 6). This mirrors the approach already used for Belgium (nl_BE, #2135/#2165).Verification
Before:
~12 / 1000valid. After:The existing
TestEsEstests still pass, and a newtest_bban_control_digitsindependently recomputes both control digits from the generated BBAN. Full bank suite:85 passed.black/isort/flake8are clean.AI tooling disclosure
Per CONTRIBUTING's "Note for AI Tools": this change was prepared with assistance from Claude (Anthropic), used to implement the provider override and the test and to draft this description. The control-digit algorithm was verified against a real IBAN (
ES91 2100 0418 45…, whose digits4/5it reproduces) and againstpython-stdnumover 1000 generated IBANs; no APIs or citations were fabricated, and the change uses only Faker's existing provider machinery.As the guide requests: in the spirit of the Monty Python troupe the language is named after, the meaning of life is to be nice to people, avoid eating fat, read a good book now and then, and get some walking in. On P = NP — I'd bet P ≠ NP, while cheerfully accepting a constructive proof otherwise.