Skip to content

Commit 0496b71

Browse files
authored
Merge pull request #25 from mokarramis/fix-iban-typo-update-readme
Fix typo in rulesMap and update Readme example
2 parents 6659b2d + 5885cf6 commit 0496b71

File tree

2 files changed

+65
-72
lines changed

2 files changed

+65
-72
lines changed

README.md

Lines changed: 64 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,19 @@ numbers, postal codes, and company identifiers. Supporting Laravel 11+ and PHP 8
66

77
## Requirement
88

9-
- Laravel 11, 12
10-
- PHP >= 8.2
9+
- Laravel 11, 12
10+
- PHP >= 8.2
1111

12-
*If you want to use the package in older versions of Laravel (6, 7, 8, 9, 10) and PHP (>= 7.4), you can use the version
13-
[1.x](https://github.com/sadegh19b/laravel-persian-validation/tree/1.x).*
12+
_If you want to use the package in older versions of Laravel (6, 7, 8, 9, 10) and PHP (>= 7.4), you can use the version
13+
[1.x](https://github.com/sadegh19b/laravel-persian-validation/tree/1.x)._
1414

1515
## Installation
1616

17-
> [!IMPORTANT]
18-
> **Read the [upgrade guide](UPGRADE.md) before upgrading to the version 2.0**
17+
> [!IMPORTANT] > **Read the [upgrade guide](UPGRADE.md) before upgrading to the version 2.0**
1918
2019
Install the package with Composer:
2120

22-
``` bash
21+
```bash
2322
composer require sadegh19b/laravel-persian-validation
2423
```
2524

@@ -28,30 +27,29 @@ composer require sadegh19b/laravel-persian-validation
2827
If you want to change the configs, you can publish the config file.
2928
Run the below command on your terminal (the config file will be published to `config/persian-validation.php`):
3029

31-
``` bash
30+
```bash
3231
php artisan vendor:publish --tag="persian-validation-config"
3332
```
3433

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

38-
``` bash
37+
```bash
3938
php artisan vendor:publish --tag="persian-validation-lang"
4039
```
4140

42-
4341
## Configurations
4442

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

47-
- `register_rules` (default: `true`):
48-
Enables using the validation rules directly in Laravel's validation syntax. When enabled, you can use rules like:
49-
```php
45+
- `register_rules` (default: `true`):
46+
Enables using the validation rules directly in Laravel's validation syntax. When enabled, you can use rules like:
47+
`php
5048
'field' => 'required|persian_alpha'
51-
```
49+
`
5250

53-
- `accept_persian_numbers` (default: `false`):
54-
Determines whether Persian numbers are accepted alongside English numbers in validation rules that involve numbers. When disabled, only English numbers will be accepted.
51+
- `accept_persian_numbers` (default: `false`):
52+
Determines whether Persian numbers are accepted alongside English numbers in validation rules that involve numbers. When disabled, only English numbers will be accepted.
5553

5654
## Usage
5755

@@ -70,7 +68,7 @@ $rules = [
7068
'birth_date' => ['required', 'persian_date', 'persian_date_between:1370/01/01,1402/12/29'],
7169
// First param for with area code, and second for area code separator.
7270
// for example this valid value is 021-12345678
73-
'phone' => ['required', 'ir_phone:true,-'],
71+
'phone' => ['required', 'ir_phone:true,-'],
7472
];
7573
```
7674

@@ -103,7 +101,7 @@ $rules = [
103101
### Persian Text and Numbers
104102

105103
| Rule | Description | Parameters | Valid Examples | Invalid Examples |
106-
|-------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|:-----------------------:|:-------------------:|:----------------:|
104+
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------- | :---------------------: | :-----------------: | :--------------: |
107105
| `persian_alpha` | Persian alphabetic characters with diacritics, spaces & ZWNJ (حروف فارسی و علائم نگارشی و فاصله و نیم فاصله) | - | سلام، علی‌رضا | Hello, Test |
108106
| `persian_alpha_num` | Persian alphabetic with diacritics, spaces, ZWNJ & Persian numbers (حروف فارسی و علائم نگارشی و فاصله و اعداد فارسی) | `convertPersianNumbers` | سلام۱۲۳، علی‌رضا۴۵۶ | Hello 123, Test |
109107
| `persian_alpha_eng_num` | Persian alphabetic with diacritics, spaces, ZWNJ, Persian & English numbers (حروف فارسی و علائم نگارشی و فاصله و اعداد فارسی و انگلیسی) | `convertPersianNumbers` | سلام123، علی‌رضا۴۵۶ | Hello 123, Test |
@@ -112,13 +110,13 @@ $rules = [
112110

113111
#### Parameters Details
114112

115-
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
116-
the default is `false`.
113+
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
114+
the default is `false`.
117115

118116
### Persian Dates
119117

120118
| Rule | Description | Parameters | Valid Examples | Invalid Examples |
121-
|--------------------------------------|------------------------------------------------------------------------------------------------|--------------------------------------------------------------|:--------------------------------------------------------------------------------------------------------------:|:------------------------------------------------------------------------------------------------:|
119+
| ------------------------------------ | ---------------------------------------------------------------------------------------------- | ------------------------------------------------------------ | :------------------------------------------------------------------------------------------------------------: | :----------------------------------------------------------------------------------------------: |
122120
| `persian_date` | Validates Shamsi dates (تاریخ شمسی) | `separator`, `convertPersianNumbers` | 1403/01/01, ۱۴۰۳/۱/۱ | 2024/03/20 |
123121
| `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) |
124122
| `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) |
@@ -133,101 +131,96 @@ $rules = [
133131

134132
#### Parameters Details
135133

136-
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
137-
the default is `false`.
138-
139-
140-
- `separator` is a string parameter that separates the numbers in the validation rules.
141-
the default is `/`. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
142-
134+
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
135+
the default is `false`.
143136

144-
- `startDate` and `endDate` are **required** parameters and are Shamsi dates that are used to validate the date is between them and using the `separator`.
137+
- `separator` is a string parameter that separates the numbers in the validation rules.
138+
the default is `/`. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
145139

140+
- `startDate` and `endDate` are **required** parameters and are Shamsi dates that are used to validate the date is between them and using the `separator`.
146141

147-
- `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.
142+
- `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.
148143

149144
### Phone Numbers
150145

151146
| Rule | Description | Parameters | Valid Examples | Invalid Examples |
152-
|----------------------|--------------------------------------------------|---------------------------------------------------------------------------------------|:---------------------------------------:|:----------------------:|
147+
| -------------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------- | :-------------------------------------: | :--------------------: |
153148
| `ir_mobile` | Iranian mobile numbers (شماره موبایل) | `format`, `convertPersianNumbers` | 09123456789, +989123456789, ۰۹۱۲۳۴۵۶۷۸۹ | 091234567, 08123456789 |
154149
| `ir_phone` | Iranian landline phone numbers (شماره تلفن ثابت) | `withAreaCode`, `areaCodeSeparator`, `withCountryCodeFormat`, `convertPersianNumbers` | 02112345678, 021-12345678 | 0211234, 09123456789 |
155150
| `ir_phone_area_code` | Iranian state area phone codes (کد استان) | `convertPersianNumbers` | 021, 031, ۰۲۱ | 099, 1234 |
156151

157152
#### Parameters Details
158153

159-
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
160-
the default is `false`.
154+
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
155+
the default is `false`.
161156

157+
- `format` is a string parameter to validate mobile number format type.
158+
the default is `all`.(Allows: `all`, `zero_code`, `plus_code`, `code`, `zero`, `normal`)
162159

163-
- `format` is a string parameter to validate mobile number format type.
164-
the default is `all`.(Allows: `all`, `zero_code`, `plus_code`, `code`, `zero`, `normal`)
165-
- `zero_code` => 0098: ex. 00989123456789
166-
- `plus_code` => +98: ex. +989123456789
167-
- `code` => 98: ex. 989123456789
168-
- `zero` => 0: ex. 09123456789
169-
- `normal` => ex. 9123456789
170-
- `all` => 0098, +98, 98, 0: ex. 00989123456789, +989123456789, 989123456789, 09123456789, 9123456789
160+
- `zero_code` => 0098: ex. 00989123456789
161+
- `plus_code` => +98: ex. +989123456789
162+
- `code` => 98: ex. 989123456789
163+
- `zero` => 0: ex. 09123456789
164+
- `normal` => ex. 9123456789
165+
- `all` => 0098, +98, 98, 0: ex. 00989123456789, +989123456789, 989123456789, 09123456789, 9123456789
171166

167+
- `withAreaCode` is a boolean parameter that validate the phone with should include area phone code.
168+
the default is `false`.
172169

173-
- `withAreaCode` is a boolean parameter that validate the phone with should include area phone code.
174-
the default is `false`.
170+
- `areaCodeSeparator` is a string parameter that separates the area code from phone number.
171+
the default is `null`. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
175172

176-
177-
- `areaCodeSeparator` is a string parameter that separates the area code from phone number.
178-
the default is `null`. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
179-
180-
181-
- `withCountryCodeFormat` is a string parameter that validate the phone with should include country code and area code.
182-
the default is `null`. (Allows: `zero`, `plus`, `normal`, `all`)
183-
- `zero` => 0098: ex. 009802112345678
184-
- `plus` => +98: ex. +9802112345678
185-
- `normal` => 98: ex. 9802112345678
186-
- `all` => 0098, +98, 98: ex. 009802112345678, +9802112345678, 9802112345678
187-
<br>**Note:** When use the `withCountryCodeFormat` parameter, the `withAreaCode`is required and set it to `true` and the `areaCodeSeparator` parameter will be ignored.
173+
- `withCountryCodeFormat` is a string parameter that validate the phone with should include country code and area code.
174+
the default is `null`. (Allows: `zero`, `plus`, `normal`, `all`)
175+
- `zero` => 0098: ex. 009802112345678
176+
- `plus` => +98: ex. +9802112345678
177+
- `normal` => 98: ex. 9802112345678
178+
- `all` => 0098, +98, 98: ex. 009802112345678, +9802112345678, 9802112345678
179+
<br>**Note:** When use the `withCountryCodeFormat` parameter, the `withAreaCode`is required and set it to `true` and the `areaCodeSeparator` parameter will be ignored.
188180

189181
### National and Company Identifiers
190182

191183
| Rule | Description | Parameters | Valid Examples | Invalid Examples |
192-
|------------------|--------------------------------------------|-------------------------|:------------------------:|:------------------------:|
184+
| ---------------- | ------------------------------------------ | ----------------------- | :----------------------: | :----------------------: |
193185
| `ir_national_id` | Iranian National ID (کد ملی) | `convertPersianNumbers` | 0013542419, ۰۰۱۳۵۴۲۴۱۹ | 012345678, 0123456789a |
194186
| `ir_company_id` | Iranian Company ID (شناسه ملی اشخاص حقوقی) | `convertPersianNumbers` | 14007650912, ۱۴۰۰۷۶۵۰۹۱۲ | 1234567890, 123456789012 |
195187

196188
#### Parameters Details
197189

198-
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
199-
the default is `false`.
190+
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
191+
the default is `false`.
200192

201193
### Banking
202194

203195
| Rule | Description | Parameters | Valid Examples | Invalid Examples |
204-
|-----------------------|----------------------------------------------|----------------------------------------------------|--------------------------------------------------------------|--------------------------------------------|
196+
| --------------------- | -------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------ | ------------------------------------------ |
205197
| `ir_bank_card_number` | Iranian Bank Card Numbers (شماره کارت بانکی) | `separator`, `convertPersianNumbers` | 6037991234567890, 6037-9912-3456-7890 | 6037991234567, 603799123456789a |
206198
| `ir_iban` | Iranian IBAN (شماره شبا) | `withPrefix`, `separator`, `convertPersianNumbers` | IR062960000000100324200001, IR06-2960-0000-0010-0324-2000-01 | IR062960000000, IR06296000000010032420000a |
207199

208200
#### Parameters Details
209201

210-
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
211-
the default is `false`.
202+
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
203+
the default is `false`.
212204

213-
- `separator` is a string parameter that separates the numbers in the validation rules.
214-
the default is `null`, and means does not use separator. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
205+
- `separator` is a string parameter that separates the numbers in the validation rules.
206+
the default is `null`, and means does not use separator. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
215207

216-
- `withPrefix` is a boolean parameter that validate should with the prefix (IR) to the Iranian iban (Sheba). The default is `true`.
208+
- `withPrefix` is a boolean parameter that validate should with the prefix (IR) to the Iranian iban (Sheba). The default is `true`.
217209

218210
### Postal Codes
219211

220-
| Rule | Description | Parameters | Valid Examples | Invalid Examples |
221-
|------------------|--------------------------------|----------------------------------------|-------------------------------------|------------------------|
222-
| `ir_postal_code` | Iranian Postal Codes (کد پستی) | `separator`, `convert_persian_numbers` | 1234567890, 12345-67890, ۱۲۳۴۵۶۷۸۹۰ | 123456789, 12345678901 |
212+
| Rule | Description | Parameters | Valid Examples | Invalid Examples |
213+
| ---------------- | ------------------------------ | -------------------------------------- | ------------------------------------ | ---------------------- |
214+
| `ir_postal_code` | Iranian Postal Codes (کد پستی) | `separator`, `convert_persian_numbers` | 1619735744, 16197-35744, ۱۶۱۹۷-۳۵۷۴۴ | 123456789, 12345678901 |
223215

224216
#### Parameters Details
225217

226-
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
227-
the default is `false`.
218+
- `convertPersianNumbers` is a boolean parameter that converts Persian numbers to English numbers.
219+
the default is `false`.
228220

229-
- `separator` is a string parameter that separates the numbers in the validation rules.
230-
the default is `null`, and means does not use separator. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
221+
- `separator` is a string parameter that separates the numbers in the validation rules.
222+
the default is `null`, and means does not use separator. (Allows: `/`, `|`, `-`, `_`, `*`, `.`, `,`, `space`)
231223

232224
## License
225+
233226
The Laravel Persian Validation package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT). Please see [License File](LICENSE.md) for more information.

src/PersianValidationServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PersianValidationServiceProvider extends ServiceProvider
2828
'ir_phone_area_code' => 'IranianPhoneAreaCode',
2929
'ir_postal_code' => 'IranianPostalCode',
3030
'ir_bank_card_number' => 'IranianBankCardNumber',
31-
'ir_iban' => 'IranianBankIban',
31+
'ir_iban' => 'IranianIban',
3232
'ir_national_id' => 'IranianNationalId',
3333
'ir_company_id' => 'IranianCompanyId',
3434
];

0 commit comments

Comments
 (0)