iranian-bank-detector
v1.0.1
Published
Detect Iranian banks from card numbers with Luhn validation, formatting, and full TypeScript support
Downloads
21
Maintainers
Readme
iranian-bank-detector
Detect Iranian banks from card numbers. Validate with Luhn. Format for display. Zero dependencies.
Installation
npm install iranian-bank-detectoryarn add iranian-bank-detector
pnpm add iranian-bank-detector
bun add iranian-bank-detectorQuick Start
import { detectBank, validateCard, formatWithSpaces } from 'iranian-bank-detector';
// Detect bank
const bank = detectBank('6037991234567890');
// → { bankName: 'meli', bankTitle: 'بانک ملی ایران', ... }
// Validate card
const isValid = validateCard('6037991234567890').isValid;
// → true
// Format for display
const formatted = formatWithSpaces('6037991234567890');
// → '6037 9912 3456 7890'Features
- 🏦 Bank Detection — Identify 30+ Iranian banks from card prefix
- ✅ Luhn Validation — Verify card number checksum
- 📝 Formatting — Display cards with spaces, dashes, or custom separators
- 🔒 Masking — Hide middle digits for security
- 🎯 TypeScript — Full type definitions included
- 📦 Zero Dependencies — Lightweight (~8KB minified)
- 🌳 Tree-shakeable — Import only what you need
API
Bank Detection
import { detectBank, getBankName, getBankLogo, getAllBanks } from 'iranian-bank-detector';
detectBank('6037991234567890');
// → { cardPrefix: 603799, bankName: 'meli', bankTitle: 'بانک ملی ایران', bankLogo: '...', color: '#1a00e0' }
getBankName('6037991234567890'); // → 'بانک ملی ایران'
getBankLogo('6037991234567890'); // → '/images/BankLogo/meli.svg'
getAllBanks(); // → BankInfo[]Validation
import { validateCard, validateLuhn, isValidCard } from 'iranian-bank-detector';
validateCard('6037991234567890');
// → { isValid: true, isLuhnValid: true, isLengthValid: true, bank: {...} }
validateLuhn('6037991234567890'); // → true
isValidCard('6037991234567890'); // → trueFormatting
import { formatWithSpaces, formatWithDashes, maskCard } from 'iranian-bank-detector';
formatWithSpaces('6037991234567890'); // → '6037 9912 3456 7890'
formatWithDashes('6037991234567890'); // → '6037-9912-3456-7890'
maskCard('6037991234567890'); // → '6037 99** **** 7890'Why This Package?
| Feature | iranian-bank-detector | Others | |---------|:---------------------:|:------:| | TypeScript support | ✅ | ⚠️ | | Zero dependencies | ✅ | ❌ | | Luhn validation | ✅ | ⚠️ | | Card formatting | ✅ | ❌ | | Card masking | ✅ | ❌ | | Tree-shakeable | ✅ | ❌ | | 30+ banks supported | ✅ | ⚠️ |
Supported Banks
| Bank | Persian | Prefix(es) | |------|---------|------------| | Meli | بانک ملی ایران | 603799 | | Mellat | بانک ملت | 610433 | | Saderat | بانک صادرات | 603769 | | Tejarat | بانک تجارت | 627353, 585983 | | Sepah | بانک سپه | 589210, 627381, 639370, 639599, 636949 | | Parsian | بانک پارسیان | 622106 | | Pasargad | بانک پاسارگاد | 502229 | | Saman | بانک سامان | 621986 | | Keshavarzi | بانک کشاورزی | 603770 | | Maskan | بانک مسکن | 628023 | | Refah | بانک رفاه | 589463 | | Shahr | بانک شهر | 504706, 502806 | | Ayandeh | بانک آینده | 636214 | | Sina | بانک سینا | 639346 | | Dey | بانک دی | 502938 | | Karafarin | بانک کارآفرین | 627488, 502910 | | ...and more | | |
Contributing
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.
License
MIT © Max Base
تشخیص بانک ایرانی
تشخیص بانک از شماره کارت | اعتبارسنجی Luhn | فرمتبندی | بدون وابستگی
نصب
npm install iranian-bank-detectorشروع سریع
import { detectBank, validateCard, formatWithSpaces } from 'iranian-bank-detector';
// تشخیص بانک
const bank = detectBank('6037991234567890');
console.log(bank.bankTitle); // 'بانک ملی ایران'
// اعتبارسنجی
const isValid = validateCard('6037991234567890').isValid; // true
// فرمتبندی
const formatted = formatWithSpaces('6037991234567890'); // '6037 9912 3456 7890'ویژگیها
- 🏦 تشخیص ۳۰+ بانک ایرانی
- ✅ اعتبارسنجی با الگوریتم Luhn
- 📝 فرمتبندی شماره کارت
- 🔒 مخفیسازی ارقام میانی
- 🎯 پشتیبانی کامل TypeScript
- 📦 بدون وابستگی خارجی
