Skip to main content
Iranian Sheba codes follow the ISO 13616 IBAN standard: the literal IR followed by 24 digits (2-digit check + 3-digit bank code + 19-digit account part). Persian Tools provides validation via isShebaValid and rich info lookup via getShebaInfo.

Functions

isShebaValid(shebaCode)

import { isShebaValid } from "@persian-tools/persian-tools";

isShebaValid("IR820540102680020817909002"); // true
isShebaValid("IR000000000000000000000000"); // false
isShebaValid("IR82 0540 1026 ..."); // false (no auto-trim)
Returns boolean. Uses the ISO 7064 mod-97 check with chunked arithmetic (no BigInt, browser-safe).

getShebaInfo(shebaCode)

Returns rich bank info — or null if the Sheba is invalid or the bank code isn’t in the table.
import { getShebaInfo } from "@persian-tools/persian-tools";

getShebaInfo("IR820540102680020817909002");
// {
//   name: "Parsian Bank",
//   nickname: "parsian",
//   persianName: "بانک پارسیان",
//   code: "054",
//   accountNumberAvailable: true,
//   accountNumber: "020817909002",
//   formattedAccountNumber: "020-8179-090-02",
// }
For banks where the library knows how to extract the account number, the result is ShebaResultWithAccountNumber (accountNumberAvailable: true). Otherwise it’s ShebaResultWithoutAccountNumber (accountNumberAvailable: false).

Types

type ShebaResultWithAccountNumber = {
	name: string;
	nickname: string;
	persianName: string;
	code: string;
	accountNumberAvailable: true;
	accountNumber: string;
	formattedAccountNumber: string;
};

type ShebaResultWithoutAccountNumber = {
	name: string;
	nickname: string;
	persianName: string;
	code: string;
	accountNumberAvailable: false;
};
The accountNumberAvailable flag is a discriminant — narrow the union with it:
const info = getShebaInfo(input);
if (!info) return notify("invalid IBAN");

if (info.accountNumberAvailable) {
	console.log(info.accountNumber); // typed string
} else {
	console.log(info.persianName); // bank name only
}

Exported regexes

import { shebaPattern, shebaPatternCode } from "@persian-tools/persian-tools";

shebaPattern; // /IR[0-9]{24}/
shebaPatternCode; // /IR[0-9]{2}([0-9]{3})[0-9]{19}/  — captures bank code

Pitfalls

  • The validator is isShebaValid, not verifySheba. No verifySheba function exists.
  • The bank’s Persian name is persianName, not bankName. There is no bankName field.
  • No automatic whitespace handling. Strip spaces in the caller: code.replace(/\s/g, "").toUpperCase().
  • No automatic Persian/Arabic digit normalization. Run autoConvertDigitsToEN upstream if input may contain them.

Source

src/modules/sheba/index.ts, src/modules/sheba/helpers.ts (chunked mod-97), src/modules/sheba/codes.skip.ts (bank table) · Tests: test/sheba.spec.ts