Skip to content

feat: add IBAN (International Bank Account Number) type#372

Merged
yezz123 merged 2 commits intopydantic:mainfrom
toroleapinc:feat/issue-10-add-iban-type
Mar 15, 2026
Merged

feat: add IBAN (International Bank Account Number) type#372
yezz123 merged 2 commits intopydantic:mainfrom
toroleapinc:feat/issue-10-add-iban-type

Conversation

@toroleapinc
Copy link
Contributor

Summary

Add a new IBAN type for validating International Bank Account Numbers.

Closes #10

Features

  • Full MOD-97 checksum validation (ISO 7064)
  • Country code validation against 70+ known IBAN country codes
  • Per-country length validation
  • Automatic normalization (uppercase, space removal)
  • Descriptive error messages for each validation failure

Usage

from pydantic import BaseModel
from pydantic_extra_types.iban import IBAN

class BankAccount(BaseModel):
    iban: IBAN

account = BankAccount(iban='GB29 NWBK 6016 1331 9268 19')
print(account.iban)  # GB29NWBK60161331926819

Tests

Includes tests for:

  • Valid IBANs from 14+ countries
  • Space normalization and case normalization
  • Invalid IBANs (wrong length, unknown country, bad checksum, etc.)

Add a new IBAN type with full validation:
- Country code validation against known IBAN country codes
- Length validation per country
- MOD-97 checksum validation (ISO 7064)
- Automatic normalization (uppercase, space removal)

Includes comprehensive tests for valid and invalid IBANs.

Closes pydantic#10

Signed-off-by: edvatar <88481784+toroleapinc@users.noreply.github.com>
Copy link
Collaborator

@yezz123 yezz123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good, can you please fix the linting issue, and I will be happy to merge it

@toroleapinc
Copy link
Contributor Author

@yezz123 Thanks for the approval! I'll fix the linting issue right away. Let me run the linters and push a fix.

Appreciate you taking the time to review!

@yezz123
Copy link
Collaborator

yezz123 commented Mar 13, 2026

Hello @toroleapinc is this fixed so we can merge it and create a release 🙌🏻

@toroleapinc
Copy link
Contributor Author

@yezz123 Just pushed the formatting fix — ruff wanted the dict expanded to one entry per line. CI should be green now. Ready to merge whenever you are!

@yezz123 yezz123 merged commit 6fc6756 into pydantic:main Mar 15, 2026
10 checks passed
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.

Add IBAN Type to Types

2 participants