Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Bank Account

Generate, validate, and format bank account numbers for 159 countries. Includes specific implementations for 16 major economies with IBAN support for 124 countries.

Generate

Rust

#![allow(unused)]
fn main() {
use rand::thread_rng;
use idsmith::bank_account::GenOptions;

let mut rng = thread_rng();
let registry = idsmith::bank_accounts();

let result = registry.generate("US", &GenOptions::default(), &mut rng).unwrap();
// result.formatted → "021000021 | 123456789"
// result.raw       → "021000021123456789"
// result.iban      → None (US doesn't use IBAN)

// IBAN countries include the IBAN
let de = registry.generate("DE", &GenOptions::default(), &mut rng).unwrap();
// de.iban → Some("DE47508562162522867909")
}

Python

import idsmith

result = idsmith.BankAccount.generate("US")
print(result["formatted"])  # 021000021 | 123456789
print(result["iban"])       # None

# With bank code filter
result = idsmith.BankAccount.generate("US", bank_code="021000021")

JavaScript

const { BankAccount } = require('idsmith');

const result = BankAccount.generate('US');
console.log(result.formatted);  // 021000021 | 123456789
console.log(result.iban);       // null

// With bank code filter
const result2 = BankAccount.generate('US', '021000021');

Validate

Rust

#![allow(unused)]
fn main() {
let valid = idsmith::bank_accounts().validate("MX", "167078019952865929").unwrap();
}

Python

valid = idsmith.BankAccount.validate("MX", "167078019952865929")

JavaScript

const valid = BankAccount.validate('MX', '167078019952865929');

Format

Rust

#![allow(unused)]
fn main() {
let formatted = idsmith::bank_accounts().format("US", "021000021123456789").unwrap();
}

Python

formatted = idsmith.BankAccount.format("US", "021000021123456789")

JavaScript

const formatted = BankAccount.format('US', '021000021123456789');

Specific Country Formats

CountryFormatHas IBAN
USABA Routing + AccountNo
CAInstitution + Transit + AccountNo
MXCLABE (18 digits)No
AUBSB + AccountNo
INIFSC + AccountNo
JPBank + Branch + AccountNo
CNBank Account (Luhn)No
GBSort Code + AccountYes
BRBank + Branch + AccountNo
ARCBUNo
NGNUBANNo
+ 85IBAN-based accountsYes
+ 140Generic bank formatsVaries