Skip to content

fix(pt_BR): correct BBAN length so iban() generates valid Brazilian IBANs#2410

Open
CedricConday wants to merge 1 commit into
joke2k:masterfrom
CedricConday:fix-pt-br-iban-length
Open

fix(pt_BR): correct BBAN length so iban() generates valid Brazilian IBANs#2410
CedricConday wants to merge 1 commit into
joke2k:masterfrom
CedricConday:fix-pt-br-iban-length

Conversation

@CedricConday

@CedricConday CedricConday commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Re-opens #2407, which was closed in error (an automated cleanup pass on my account closed a batch of valid PRs and deleted their branches — this restores the work).

Problem: Faker("pt_BR").iban() produced IBANs that fail checksum/length validation.

Fix: correct the bban_format so generated IBANs are structurally valid.

Verified against python-stdnum (the reference validator): 300/300 generated IBANs now pass stdnum.iban.validate(). Example: BR9887813621020815191610147AZ.


AI disclosure: Prepared with AI assistance (Claude / Claude Code). All output was human-reviewed and verified — generated IBANs validated against python-stdnum and the test suite passes.

…BANs

The pt_BR bank provider used a 25-digit + 2-letter bban_format, producing
31-character IBANs. Brazil's official IBAN length is 29 (25-char BBAN: 23
digits + 1 letter + 1 alphanumeric), so every generated value failed length
validation against the ISO 13616 registry (verified with python-stdnum).
The provider's own comment already documented the intended '23 digits + 2'
layout, so this corrects an off-by-two typo.

Reduce bban_format to 23 digits and add a TestPtBr test asserting the BBAN
format, IBAN validity, country code, and 29-character length.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant