Skip to content
Amir Iranmanesh edited this page Aug 11, 2026 · 2 revisions

bank

Validate Iranian bank card numbers, resolve the issuing bank, and validate Sheba (IBAN) codes.

import "github.com/amiranmanesh/go-persian-tools/bank"

Card numbers

name, err := bank.CardInfo("6037701689095443") // "keshavarzi", nil

The number must be 16 digits and pass the Luhn checksum; the bank is then resolved from the six-digit prefix (BIN).

Error When
bank.ErrInvalidCard not 16 digits, or fails the Luhn checksum
bank.ErrBankNotFound valid number, but no bank matches the prefix
if _, err := bank.CardInfo(input); errors.Is(err, bank.ErrInvalidCard) {
    // tell the user the number itself is wrong
}

Sheba (IBAN)

sheba := bank.ShebaCode{Code: "IR820540102680020817909002"}

sheba.IsValid() // structure + ISO 7064 MOD-97-10 checksum

info := sheba.IsSheba()
info.Name        // Parsian Bank
info.PersianName // بانک پارسیان
info.Code        // 054

IsValid answers only "is this a well-formed Iranian IBAN". IsSheba additionally looks the bank up and returns a zero ShebaResult when the code is valid but the bank is unknown — so a true from IsValid with an empty Name means "correct checksum, unrecognized bank".

ShebaResult

type ShebaResult struct {
    MergedInto             string
    Name                   string
    Code                   string
    NickName               string
    PersianName            string
    AccountNumber          string
    AccountNumberAvailable bool
    FormattedAccountNumber string
    Process                func(str string) ShebaProcess
}

AccountNumberAvailable reports whether the bank publishes enough structure to recover the account number from the IBAN; when it does, Process extracts it.

Merged banks

Bank Sepah absorbed five institutions between 2019 and 2020:

Code Bank
052 قوامین (Ghavamin) → sepah
063 انصار (Ansar) → sepah
065 حکمت ایرانیان (Hekmat Iranian) → sepah
073 مؤسسه کوثر (Kosar) → sepah
079 مهر اقتصاد (Mehr Eqtesad) → sepah

Their codes stay in the table because IBANs issued before the merger are still valid and still have to resolve. Each is marked with MergedInto: "sepah", so you can surface "this account has moved to Bank Sepah" instead of failing.

Clone this wiki locally