PHPackages                             sadegh19b/laravel-persian-validation - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. sadegh19b/laravel-persian-validation

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

sadegh19b/laravel-persian-validation
====================================

A comprehensive Laravel validation package for Persian text, numbers, dates, and Iranian national identifiers

v2.0.9(7mo ago)18293.8k↓47.2%211MITPHPPHP &gt;=8.2

Since Sep 18Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/sadegh19b/laravel-persian-validation)[ Packagist](https://packagist.org/packages/sadegh19b/laravel-persian-validation)[ Docs](https://github.com/sadegh19b/laravel-persian-validation)[ RSS](/packages/sadegh19b-laravel-persian-validation/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (31)Used By (1)

[![PHP Version Require](https://camo.githubusercontent.com/47e19d44e4516e59ce8998703b5d3d19500c8a7038edf788a4fcbce5ecab7297/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f7361646567683139622f6c61726176656c2d7065727369616e2d76616c69646174696f6e2f7068702e737667)](https://packagist.org/packages/sadegh19b/laravel-persian-validation)[![Total Downloads](https://camo.githubusercontent.com/cc6c761117b6796549914232644f6cf15c627c0601464d45c7c96c2b450b1936/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7361646567683139622f6c61726176656c2d7065727369616e2d76616c69646174696f6e2e7376673f636f6c6f723d627269676874677265656e)](https://packagist.org/packages/sadegh19b/laravel-persian-validation)[![License](https://camo.githubusercontent.com/01fe2f9afca0e7f06a682c98a187a2a3e9461abc10729d3a904d77eb0c2b28e6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7361646567683139622f6c61726176656c2d7065727369616e2d76616c69646174696f6e2e737667)](https://packagist.org/packages/sadegh19b/laravel-persian-validation)

Laravel Persian Validation
==========================

[](#laravel-persian-validation)

Laravel Persian Validation provides validation rules for Persian alphabet, numbers and Iranian-specific data formats. It offers comprehensive validation for Persian (Shamsi) dates, phone numbers, national IDs, bank cards, Sheba numbers, postal codes, and company identifiers. Supporting Laravel 11+ and PHP 8.2+, it seamlessly integrates with Laravel's validation system.

Requirement
-----------

[](#requirement)

- Laravel 11, 12
- PHP &gt;= 8.2

> ⚠️ If you need to use the package with older versions of Laravel (6, 7, 8, 9, 10) and PHP (&gt;= 7.4), please use version [1.x](https://github.com/sadegh19b/laravel-persian-validation/tree/1.x)

Installation
------------

[](#installation)

Important

**Read the [upgrade guide](UPGRADE.md) before upgrading to the version 2.0**

Install the package with Composer:

```
composer require sadegh19b/laravel-persian-validation
```

Publish
-------

[](#publish)

If you want to change the configs, you can publish the config file. Run the below command on your terminal (the config file will be published to `config/persian-validation.php`):

```
php artisan vendor:publish --tag="persian-validation-config"
```

If you want to use validations custom messages, you can publish language file. Run the below command on your terminal (the language file will be published to `lang/vendor/persianValidation/{locale}/persian-validation.php`. supported locales: `en`, `fa`):

```
php artisan vendor:publish --tag="persian-validation-lang"
```

Configurations
--------------

[](#configurations)

The package provides below configuration options in `config/persian-validation.php`:

- `register_rules` (default: `true`): Enables using the validation rules directly in Laravel's validation syntax. When enabled, you can use rules like: `php 'field' => 'required|persian_alpha' `
- `accept_persian_numbers` (default: `false`): Determines whether Persian numbers are accepted alongside English numbers in validation rules that involve numbers. When disabled, only English numbers will be accepted.

Usage
-----

[](#usage)

When the `register_rules` is `true` in configuration:

```
// Basic usage
$rules = [
    'name' => 'required|persian_alpha',
    'mobile' => 'required|ir_mobile',
    'code_melli' => 'required|ir_national_id',
];

// With parameters
$rules = [
    'birth_date' => ['required', 'persian_date', 'persian_date_between:1370/01/01,1402/12/29'],
    // First param for with area code, and second for area code separator.
    // for example this valid value is 021-12345678
    'phone' => ['required', 'ir_phone:true,-'],
];
```

When the rules not registered in laravel validation container:

```
use Sadegh19b\LaravelPersianValidation\Rules\PersianAlpha;
use Sadegh19b\LaravelPersianValidation\Rules\IranianMobile;
use Sadegh19b\LaravelPersianValidation\Rules\IranianNationalId;
use Sadegh19b\LaravelPersianValidation\Rules\PersianDate;

// Basic usage
$rules = [
    'name' => ['required', new PersianAlpha],
    'mobile' => ['required', new IranianMobile],
    'code_melli' => ['required', new IranianNationalId],
];

// With parameters
$rules = [
    'birth_date' => ['required', new PersianDate(separator: '-')],
    'phone' => ['required', new IranianPhone(withAreaCode: true, areaCodeSeparator: '-')],
];
```

Rules
-----

[](#rules)

**Note:** All parameters in below tables are in order to be used, must be passed to the rule constructor.

### Persian Text and Numbers

[](#persian-text-and-numbers)

RuleDescriptionParametersValid ExamplesInvalid Examples`persian_alpha`Persian alphabetic characters with diacritics, spaces &amp; ZWNJ (حروف فارسی و علائم نگارشی و فاصله و نیم فاصله)-سلام، علی‌رضاHello, Test`persian_alpha_num`Persian alphabetic with diacritics, spaces, ZWNJ &amp; Persian numbers (حروف فارسی و علائم نگارشی و فاصله و اعداد فارسی)`convertPersianNumbers`سلام۱۲۳، علی‌رضا۴۵۶Hello 123, Test`persian_alpha_eng_num`Persian alphabetic with diacritics, spaces, ZWNJ, Persian &amp; English numbers (حروف فارسی و علائم نگارشی و فاصله و اعداد فارسی و انگلیسی)`convertPersianNumbers`سلام123، علی‌رضا۴۵۶Hello 123, Test`persian_num`Only Persian numbers (اعداد فارسی)-۱۲۳۴۵۶۷۸۹۰1234567890`persian_not_accept`Rejects Persian characters and numbers (موارد فارسی غیرقابل قبول)-Hello 123, Testسلام، تست۱۲۳#### Parameters Details

[](#parameters-details)

- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers. the default is `false`.

### Persian Dates

[](#persian-dates)

RuleDescriptionParametersValid ExamplesInvalid Examples`persian_date`Validates Shamsi dates (تاریخ شمسی)`separator`, `convertPersianNumbers`1403/01/01, ۱۴۰۳/۱/۱2024/03/20`persian_date_between`Validates date is between two Shamsi dates (تاریخ مابین دو تاریخ شمسی)`startDate`, `endDate`, `separator`, `convertPersianNumbers`1403/01/01 (if between range)1402/12/29 (if outside range)`persian_date_between_or_equal`Validates date is between or equal to two Shamsi dates (تاریخ مابین یا برابر با دو تاریخ شمسی)`startDate`, `endDate`, `separator`, `convertPersianNumbers`1403/01/01 (if between range)1402/12/29 (if outside range)`persian_date_between_year`Validates year is between two Shamsi years (تاریخ مابین اسال های شمسی)`startYear`, `endYear`, `separator`, `convertPersianNumbers`1403/01/01 (if year in range)1402/01/01 (if year outside range)`persian_date_between_or_equal_year`Validates year is between or equal to two Shamsi years (تاریخ مابین یا برابر با سال های شمسی)`startYear`, `endYear`, `separator`, `convertPersianNumbers`1403/01/01 (if year in range)1402/01/01 (if year outside range)`persian_day`Validates the persian date name (روزهای هفته)-Allows (`شنبه`, `یکشنبه`, `دوشنبه`, `سه‌شنبه`, `چهارشنبه`, `پنج‌شنبه`, `جمعه`)Saturday, Sunday, Monday, Tuesday, Wednesday, Thursday, Friday`persian_month`Validates the persian month name (ماه‌های شمسی)-Allows (`فروردین`, `اردیبهشت`, `خرداد`, `تیر`, `مرداد`, `شهریور`, `مهر`, `آبان`, `آذر`, `دی`, `بهمن`, `اسفند`)January, February, March, April, May, June, July, August, September, October, November, December**Note:** The dates validate between 1000 and 1600 years.

**Note:** The validation values for `persian_day` and `persian_month` rules can be customized by modifying the corresponding values in the language file (`lang/{locale}/persian-validation.php`).

#### Parameters Details

[](#parameters-details-1)

- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers. the default is `false`.
- `separator` is a string parameter that separates the numbers in the validation rules. the default is `/`. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
- `startDate` and `endDate` are **required** parameters and are Shamsi dates that are used to validate the date is between them and using the `separator`.
- `startYear` and `endYear` are **required** parameters and are Shamsi years that are used to validate the year is between them and the 4-digit acceptable.

### Phone Numbers

[](#phone-numbers)

RuleDescriptionParametersValid ExamplesInvalid Examples`ir_mobile`Iranian mobile numbers (شماره موبایل)`format`, `convertPersianNumbers`09123456789, +989123456789, ۰۹۱۲۳۴۵۶۷۸۹091234567, 08123456789`ir_phone`Iranian landline phone numbers (شماره تلفن ثابت)`withAreaCode`, `areaCodeSeparator`, `withCountryCodeFormat`, `convertPersianNumbers`02112345678, 021-123456780211234, 09123456789`ir_phone_area_code`Iranian state area phone codes (کد استان)`convertPersianNumbers`021, 031, ۰۲۱099, 1234#### Parameters Details

[](#parameters-details-2)

- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers. the default is `false`.
- `format` is a string parameter to validate mobile number format type. the default is `all`.(Allows: `all`, `zero_code`, `plus_code`, `code`, `zero`, `normal`)

    - `zero_code` =&gt; 0098: ex. 00989123456789
    - `plus_code` =&gt; +98: ex. +989123456789
    - `code` =&gt; 98: ex. 989123456789
    - `zero` =&gt; 0: ex. 09123456789
    - `normal` =&gt; ex. 9123456789
    - `all` =&gt; 0098, +98, 98, 0: ex. 00989123456789, +989123456789, 989123456789, 09123456789, 9123456789
- `withAreaCode` is a boolean parameter that validate the phone with should include area phone code. the default is `false`.
- `areaCodeSeparator` is a string parameter that separates the area code from phone number. the default is `null`. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
- `withCountryCodeFormat` is a string parameter that validate the phone with should include country code and area code. the default is `null`. (Allows: `zero`, `plus`, `normal`, `all`)

    - `zero` =&gt; 0098: ex. 009802112345678
    - `plus` =&gt; +98: ex. +9802112345678
    - `normal` =&gt; 98: ex. 9802112345678
    - `all` =&gt; 0098, +98, 98: ex. 009802112345678, +9802112345678, 9802112345678
        **Note:** When use the `withCountryCodeFormat` parameter, the `withAreaCode`is required and set it to `true` and the `areaCodeSeparator` parameter will be ignored.

### National and Company Identifiers

[](#national-and-company-identifiers)

RuleDescriptionParametersValid ExamplesInvalid Examples`ir_national_id`Iranian National ID (کد ملی)`convertPersianNumbers`0013542419, ۰۰۱۳۵۴۲۴۱۹012345678, 0123456789a`ir_company_id`Iranian Company ID (شناسه ملی اشخاص حقوقی)`convertPersianNumbers`14007650912, ۱۴۰۰۷۶۵۰۹۱۲1234567890, 123456789012#### Parameters Details

[](#parameters-details-3)

- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers. the default is `false`.

### Banking

[](#banking)

RuleDescriptionParametersValid ExamplesInvalid Examples`ir_bank_card_number`Iranian Bank Card Numbers (شماره کارت بانکی)`separator`, `convertPersianNumbers`6037991234567890, 6037-9912-3456-78906037991234567, 603799123456789a`ir_iban`Iranian IBAN (شماره شبا)`withPrefix`, `separator`, `convertPersianNumbers`IR062960000000100324200001, IR06-2960-0000-0010-0324-2000-01IR062960000000, IR06296000000010032420000a#### Parameters Details

[](#parameters-details-4)

- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers. the default is `false`.
- `separator` is a string parameter that separates the numbers in the validation rules. the default is `null`, and means does not use separator. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
- `withPrefix` is a boolean parameter that validate should with the prefix (IR) to the Iranian iban (Sheba). The default is `true`.

### Postal Codes

[](#postal-codes)

RuleDescriptionParametersValid ExamplesInvalid Examples`ir_postal_code`Iranian Postal Codes (کد پستی)`separator`, `convert_persian_numbers`1619735744, 16197-35744, ۱۶۱۹۷-۳۵۷۴۴123456789, 12345678901#### Parameters Details

[](#parameters-details-5)

- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers. the default is `false`.
- `separator` is a string parameter that separates the numbers in the validation rules. the default is `null`, and means does not use separator. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)

License
-------

[](#license)

The Laravel Persian Validation package is open-sourced software licensed under the [MIT License](LICENSE.md).

###  Health Score

59

—

FairBetter than 99% of packages

Maintenance65

Regular maintenance activity

Popularity48

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 70.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~74 days

Recently: every ~34 days

Total

31

Last Release

210d ago

Major Versions

1.6.0 → v2.0.02025-03-01

1.x-dev → v2.0.12025-03-05

PHP version history (4 changes)1.0PHP &gt;=7.2

1.2.4PHP ~7.4|| ^8

1.5.0PHP ~7.4|^8.0|^8.1|^8.2

v2.0.0PHP &gt;=8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/72118b003b1b3a81d78c3dcc6be2580cf59c4ef0bf314c4f68d71b3dce6a3832?d=identicon)[sadegh19b](/maintainers/sadegh19b)

---

Top Contributors

[![sadegh19b](https://avatars.githubusercontent.com/u/54643531?v=4)](https://github.com/sadegh19b "sadegh19b (46 commits)")[![nimah79](https://avatars.githubusercontent.com/u/20343056?v=4)](https://github.com/nimah79 "nimah79 (4 commits)")[![ahbanavi](https://avatars.githubusercontent.com/u/39927312?v=4)](https://github.com/ahbanavi "ahbanavi (2 commits)")[![alisalehi1380](https://avatars.githubusercontent.com/u/111766206?v=4)](https://github.com/alisalehi1380 "alisalehi1380 (2 commits)")[![taha-moghaddam](https://avatars.githubusercontent.com/u/3314387?v=4)](https://github.com/taha-moghaddam "taha-moghaddam (2 commits)")[![hasanmonfared](https://avatars.githubusercontent.com/u/42858705?v=4)](https://github.com/hasanmonfared "hasanmonfared (1 commits)")[![hossein-zare](https://avatars.githubusercontent.com/u/56504893?v=4)](https://github.com/hossein-zare "hossein-zare (1 commits)")[![mojtabaRKS](https://avatars.githubusercontent.com/u/20111073?v=4)](https://github.com/mojtabaRKS "mojtabaRKS (1 commits)")[![mokarramis](https://avatars.githubusercontent.com/u/61058795?v=4)](https://github.com/mokarramis "mokarramis (1 commits)")[![mra-dev](https://avatars.githubusercontent.com/u/46625554?v=4)](https://github.com/mra-dev "mra-dev (1 commits)")[![AlirezaSedghi](https://avatars.githubusercontent.com/u/8061051?v=4)](https://github.com/AlirezaSedghi "AlirezaSedghi (1 commits)")[![NVD-R](https://avatars.githubusercontent.com/u/6688070?v=4)](https://github.com/NVD-R "NVD-R (1 commits)")[![aliakbarazizi](https://avatars.githubusercontent.com/u/8492767?v=4)](https://github.com/aliakbarazizi "aliakbarazizi (1 commits)")[![amirfallahii](https://avatars.githubusercontent.com/u/20963060?v=4)](https://github.com/amirfallahii "amirfallahii (1 commits)")

---

Tags

laravellaravel-persianlaravel-persian-validationpersianvalidatevalidationvalidatorlaravelvalidatorvalidationvalidatepersianfarsi

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sadegh19b-laravel-persian-validation/health.svg)

```
[![Health](https://phpackages.com/badges/sadegh19b-laravel-persian-validation/health.svg)](https://phpackages.com/packages/sadegh19b-laravel-persian-validation)
```

###  Alternatives

[proengsoft/laravel-jsvalidation

Validate forms transparently with Javascript reusing your Laravel Validation Rules, Messages, and FormRequest

1.1k2.3M49](/packages/proengsoft-laravel-jsvalidation)[laravel-validation-rules/credit-card

Validate credit card number, expiration date, cvc

2412.2M5](/packages/laravel-validation-rules-credit-card)[illuminatech/validation-composite

Allows uniting several validation rules into a single one for easy re-usage

184485.5k](/packages/illuminatech-validation-composite)[iamfarhad/validation

🇮🇷 Complete Laravel Persian validation package - Iranian national ID, mobile numbers, Shamsi dates, IBAN/Sheba, postal codes &amp; more. Modern Laravel 10-12 support with both ValidationRule objects &amp; string-based rules.

2917.3k](/packages/iamfarhad-validation)[stuyam/laravel-phone-validator

A phone validator for Laravel using the free Twilio phone lookup service.

2861.3k](/packages/stuyam-laravel-phone-validator)[ellisio/laravel-phone

A phone validator for Laravel using the free Twilio phone lookup service.

1130.0k](/packages/ellisio-laravel-phone)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
