majida / ir-validator
A laravel package for validate some Iranian values.
Requires
- php: >=5.0
- illuminate/support: ~5.4
- illuminate/validation: ~5.4
Requires (Dev)
- phpunit/phpunit: ~5.7
This package is not auto-updated.
Last update: 2024-12-22 06:47:45 UTC
README
A laravel package for validate some Iranian values.
This package verify these values now :
- National Code (کدملی)
- IBAN (شماره شبا)
- Debit Card (شماره کارت بانکی)
- Postal Code (کد پستی)
Installation
- Run the command below to install via Composer
composer require majida/ir-validator
- Open your
config/app.php
and add the following to theproviders
array:
Majida\IrValidator\IrValidatorServiceProvider::class,
Usage
IrValidator works same as another Laravel Validation rules.
Rules
national_code
A rule for validating Iranian national code (How calculated)
return [ 'code' => 'required|national_code' ];
--OR--
$validatedData = $request->validate([ 'code' => 'national_code', ]);
iban
A rule for validating IBAN (International Bank Account Number) known in Iran as Sheba. (How calculated)
return [ 'account' => 'iban' ];
Add false
optional parameter after iban
, If IBAN doesn't begin with IR
, so the validator will add IR
as default to the account number:
return [ 'account' => 'iban:false' ];
If you want to validate non Iranian IBAN, add the 2 letters of country code after false
optional parameter:
return [ 'account' => 'iban:false,DE' ];
debit_card
A rule for validating Iranian debit cards. (How calculated)
return [ 'code' => 'required|debit_card' ];
--OR--
$validatedData = $request->validate([ 'code' => 'debit_card', ]);
You can add an optional parameter if you want to validate a card from a specific bank:
return [ 'code' => 'required|debit_card:bmi' ];
List of the bank codes:
-
bmi (بانک ملی)
-
banksepah (بانک سپه)
-
edbi (بانک توصعه صادرات)
-
bim (بانک صنعت و معدن)
-
bki (بانک کشاورزی)
-
bank-maskan (بانک مسکن)
-
postbank (پست بانک ایران)
-
ttbank (بانک توسعه تعاون)
-
enbank (بانک اقتصاد نوین)
-
parsian-bank (بانک پارسیان)
-
bpi (بانک پاسارگاد)
-
karafarinbank (بانک کارآفرین)
-
sb24 (بانک سامان)
-
sinabank (بانک سینا)
-
sbank (بانک سرمایه)
-
shahr-bank (بانک شهر)
-
bank-day (بانک دی)
-
bsi (بانک صادرات)
-
bankmellat (بانک ملت)
-
tejaratbank (بانک تجارت)
-
refah-bank (بانک رفاه)
-
ansarbank (بانک انصار)
-
mebank (بانک مهر اقتصاد)
-
postal_code
return [ 'code' => 'required|postal_code' ];
--OR--
$validatedData = $request->validate([ 'code' => 'postal_code', ]);
Contribute
Contributions to the package are always welcome!
- Report any idea, bugs or issues you find on the issue tracker.
- You can grab the source code at the package's Git repository.
License
All contents of this package are licensed under the MIT license.