Download the PHP package fallahalireza/persian-tools-laravel without Composer
On this page you can find all versions of the php package fallahalireza/persian-tools-laravel. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download fallahalireza/persian-tools-laravel
More information about fallahalireza/persian-tools-laravel
Files in fallahalireza/persian-tools-laravel
Package persian-tools-laravel
Short Description A powerful Laravel package for Persian text utilities, Iranian validation rules, banking tools, national identifiers, Jalali dates, and more.
License MIT
Informations about the package persian-tools-laravel
🇮🇷 Persian Tools for Laravel
A powerful Laravel validation package for Persian/Iranian applications including national IDs, banking, mobile numbers, license plates, Jalali dates and more.
یک پکیج قدرتمند و جامع لاراول برای اعتبارسنجی متن فارسی، شناسههای ایرانی، بانکداری، تاریخ شمسی، پلاک خودرو و بیشتر
--- ### 🌍 Language / زبان ---🇬🇧 English Documentation
Table of Contents
- Features
- Requirements
- Installation
- Configuration
- Usage
- Validation Rules Reference
- Persian Text & Numbers
- Persian Dates
- Phone Numbers
- Identifiers
- Banking
- Other
- Enums Reference
- Localization
- Testing
- Contributing
- License
✨ Features
This package provides a rich set of Laravel validation rules tailored for Persian/Iranian applications. Below is a quick comparison with other available packages:
| Feature | This Package | Others |
|---|---|---|
| کد اقتصادی (Economic Code) validation | ✅ | ❌ |
| پلاک خودرو (License Plate) validation | ✅ | ❌ |
| شماره حساب بانکی (Bank Account Number) | ✅ | ❌ |
| Bank detection from card BIN | ✅ | ❌ |
Type-safe PersianRule Enum |
✅ | ❌ |
MobileFormat Enum |
✅ | ❌ |
| Luhn algorithm for bank cards | ✅ | ✅ |
| Full IBAN (Sheba) checksum | ✅ | ✅ |
| National ID checksum | ✅ | ✅ |
| Persian digit normalization | ✅ | partial |
| Bilingual error messages (fa/en) | ✅ | partial |
📋 Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.2 |
| Laravel | ^11.0, ^12.0, or ^13.0 |
📦 Installation
Install via Composer:
The package registers itself automatically via Laravel's package auto-discovery — no manual provider registration is needed.
Publish Config (Optional)
Publish Language Files (Optional)
⚙️ Configuration
After publishing, edit config/persian-tools.php:
🚀 Usage
There are three ways to use this package:
1. String-based Rules (requires register_rules = true)
The simplest approach — use rule names as strings:
2. Class-based Rules (always available)
Use rule classes directly for full control over parameters:
3. Type-safe Enum (always available)
Leverage the PersianRule enum to avoid typos in rule names:
📋 All Validation Rules
🔤 Persian Text & Numbers
| String Rule | Class | Description | Valid Example | Invalid Example |
|---|---|---|---|---|
persian_alpha |
PersianAlpha |
Persian letters, punctuation & spaces | سلام علیرضا |
Hello |
persian_alpha_num |
PersianAlphaNum |
Persian letters + Persian digits | سلام۱۲۳ |
Hello 123 |
persian_alpha_eng_num |
PersianAlphaEngNum |
Persian letters + Persian/English digits | سلام123 |
Hello |
persian_num |
PersianNum |
Persian digits only | ۱۲۳۴۵ |
12345 |
persian_not_accept |
PersianNotAccept |
Reject any Persian content | Hello 123 |
سلام |
📅 Persian Dates
| String Rule | Parameters | Description |
|---|---|---|
persian_date |
separator, convertPersianNumbers |
Valid Jalali (Shamsi) date |
persian_date_between |
startDate, endDate, separator, convertPersianNumbers |
Date within a range (exclusive) |
persian_month |
— | Valid Persian month name |
persian_day |
— | Valid Persian day of week name |
Examples:
📱 Phone Numbers
| String Rule | Class | Parameters | Valid Examples |
|---|---|---|---|
ir_mobile |
IranianMobile |
format, convertPersianNumbers |
09123456789, +989123456789 |
ir_phone |
IranianPhone |
withAreaCode, areaCodeSeparator, withCountryCodeFormat, convertPersianNumbers |
02112345678 |
ir_phone_area_code |
IranianPhoneAreaCode |
convertPersianNumbers |
021, 031, 044 |
Mobile Format options:
Phone with area code:
🪪 Identifiers
| String Rule | Class | Description | Valid Example |
|---|---|---|---|
ir_national_id |
IranianNationalId |
10-digit National ID with checksum | 0013542419 |
ir_company_id |
IranianCompanyId |
Legal Entity National ID (شناسه ملی اشخاص حقوقی) | 14007650912 |
ir_economic_code |
IranianEconomicCode |
14-digit Economic Code (کد اقتصادی) ⭐ | 14004800101010 |
🏦 Banking
| String Rule | Class | Description |
|---|---|---|
ir_bank_card |
IranianBankCardNumber |
16-digit bank card (Luhn algorithm + BIN detection) |
ir_iban |
IranianIban |
IBAN / Sheba number with full checksum validation |
ir_bank_account |
IranianBankAccountNumber |
Bank account number ⭐ |
Advanced banking usage:
📍 Other
| String Rule | Class | Parameters | Description |
|---|---|---|---|
ir_postal_code |
IranianPostalCode |
separator |
10-digit Iranian postal code |
ir_license_plate |
IranianLicensePlate |
allowMotorcycle |
Car & motorcycle license plate ⭐ |
Examples:
🔢 Enums Reference
PersianRule Enum
Type-safe enum mapping all rule names:
MobileFormat Enum
🌐 Localization
The package ships with Persian (fa) and English (en) error messages.
Set the default locale in config/app.php:
Override per request:
To customize messages, publish the language files and edit:
🧪 Testing
Run with coverage:
Run static analysis:
Format code:
🤝 Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'Add my feature' - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
Please make sure all tests pass and code follows PSR-12 standards before submitting.
📄 License
The MIT License (MIT). See LICENSE for more information.
Developed with ❤️ by Alireza Fallah
All versions of persian-tools-laravel with dependencies
illuminate/support Version ^11.0 || ^12.0 || ^13.0
illuminate/validation Version ^11.0 || ^12.0 || ^13.0