Skip to content

Add Indian Financial System Code (IFSC) bank branch code validation - #511

Open
yashbudhia wants to merge 1 commit into
arthurdejong:masterfrom
yashbudhia:in-ifsc
Open

Add Indian Financial System Code (IFSC) bank branch code validation#511
yashbudhia wants to merge 1 commit into
arthurdejong:masterfrom
yashbudhia:in-ifsc

Conversation

@yashbudhia

Copy link
Copy Markdown

This adds stdnum.in_.ifsc for the Indian Financial System Code, the bank branch identifier the Reserve Bank of India assigns to every branch that participates in NEFT, RTGS and IMPS. It is required for every domestic electronic funds transfer in India and is also used to route UPI payments, so it shows up in practically every Indian payments, lending and KYC system. The in_ package already covers PAN, GSTIN, Aadhaar, EPIC and VID; IFSC is the missing banking one.

Format

  • 11 characters: 4 letter bank code, a fifth character that is reserved and always 0, then a 6 character branch code.
  • The branch code is usually numeric but may contain letters, which is common for cooperative and other sub-member banks that transact through a sponsor bank (e.g. HDFC0CABBLM).
  • There is no check digit, so this is structure validation in the same spirit as stdnum.bic.

Sources

What is included

  • compact(), validate(), is_valid() and info() (returns bank_code and branch_code), following the conventions of the existing in_ modules.
  • tests/test_in_ifsc.doctest with 60 real codes taken from the Razorpay dataset, chosen to span many different banks and both numeric and alphanumeric branch codes, plus corner cases for length, the reserved fifth character, bad characters and normalisation.
  • The dataset's 1,296 representative codes were checked while writing this: all are 11 characters and every fifth character is 0, so InvalidComponent for a non-zero fifth character is justified.

Per CONTRIBUTING I have not touched NEWS, README or docs. pytest, flake8 and scripts/check_headers.py pass on the new files; mypy reports only the pre-existing zeep import notes that pan.py also reports.

The IFSC is the 11 character code the Reserve Bank of India assigns to every
bank branch on NEFT, RTGS and IMPS, and is needed for every domestic
electronic transfer and for routing UPI payments. It is a 4 letter bank
code, a reserved fifth character that is always 0, and a 6 character
alphanumeric branch code, with no check digit.

The module provides compact(), validate(), is_valid() and info() (bank and
branch code). The doctests cover 60 real codes from the openly maintained
Razorpay IFSC dataset, which is derived from the RBI's published list, and
were chosen to span many banks and both numeric and alphanumeric branch codes.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011ZJQzxtgWvkWobxsDcuLoW
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