Skip to content

Commit 3587d81

Browse files
authored
Merge pull request #48 from kiankamgar/1.x
[1.x] Add Iran postal code rule
2 parents 5e4efee + 1076921 commit 3587d81

25 files changed

+102
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ return [
102102
| 35 | ValidSnakeCase | Validate snake case for ex (milwad_dev) |
103103
| 36 | ValidVatId | Validate european VAT ID ex (EL123456789123) |
104104
| 37 | ValidIban | Validate IBAN ex (IR062960000000100324200001) |
105+
| 38 | ValidIranPostalCode | Validate Iran postal code ex (3354355599) |
105106

106107
# Rules
107108

src/Rules/ValidIranPostalCode.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
namespace Milwad\LaravelValidate\Rules;
4+
5+
use Illuminate\Contracts\Validation\Rule;
6+
7+
class ValidIranPostalCode implements Rule
8+
{
9+
/**
10+
* Check postal code is valid.
11+
*
12+
* @param string $attribute
13+
* @param mixed $value
14+
* @return bool
15+
*/
16+
public function passes($attribute, $value)
17+
{
18+
return preg_match('/^(?!(\d)\1{3})[13-9]{4}[1346-9][013-9]{5}$/', $value);
19+
}
20+
21+
/**
22+
* Get the validation error message.
23+
*
24+
* @return string
25+
*/
26+
public function message()
27+
{
28+
return __('validate.postal-code');
29+
}
30+
}

src/lang/It/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => ':attribute non è valido.',
2424
'phone-number' => ':attribute non è valido.',
2525
'port' => ':attribute non è valido.',
26+
'postal-code' => ':attribute non è valido.',
2627
'slash-end-of-string' => ':attribute non è valido.',
2728
'slug' => ':attribute non è valido.',
2829
'strong-password' => ':attribute non è valido.',

src/lang/ar/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => ':attribute غير صالح.',
2424
'phone-number' => ':attribute غير صالح.',
2525
'port' => ':attribute غير صالح.',
26+
'postal-code' => ':attribute غير صالح.',
2627
'slash-end-of-string' => ':attribute غير صالح.',
2728
'slug' => ':attribute غير صالح.',
2829
'strong-password' => ':attribute غير صالح.',

src/lang/az/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => ':attribute doğru deyil.',
2424
'phone-number' => ':attribute doğru deyil.',
2525
'port' => ':attribute doğru deyil.',
26+
'postal-code' => ':attribute doğru deyil.',
2627
'slash-end-of-string' => ':attribute doğru deyil.',
2728
'slug' => ':attribute doğru deyil.',
2829
'strong-password' => ':attribute doğru deyil.',

src/lang/ca/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => ':attribute no és vàlid.',
2424
'phone-number' => ':attribute no és vàlid.',
2525
'port' => ':attribute no és vàlid.',
26+
'postal-code' => ':attribute no és vàlid.',
2627
'slash-end-of-string' => ':attribute no és vàlid.',
2728
'slug' => ':attribute no és vàlid.',
2829
'strong-password' => ':attribute no és vàlid.',

src/lang/de/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => ':attribute kein gültiger.',
2424
'phone-number' => ':attribute kein gültiger.',
2525
'port' => ':attribute kein gültiger.',
26+
'postal-code' => ':attribute kein gültiger.',
2627
'slash-end-of-string' => ':attribute kein gültiger.',
2728
'slug' => ':attribute kein gültiger.',
2829
'strong-password' => ':attribute kein gültiger.',

src/lang/el/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => 'Το :attribute δεν είναι έγκυρο.',
2424
'phone-number' => 'Το :attribute δεν είναι έγκυρο.',
2525
'port' => 'Το :attribute δεν είναι έγκυρο.',
26+
'postal-code' => 'Το :attribute δεν είναι έγκυρο.',
2627
'slash-end-of-string' => 'Το :attribute δεν είναι έγκυρο.',
2728
'slug' => 'Το :attribute δεν είναι έγκυρο.',
2829
'strong-password' => 'Το :attribute δεν είναι έγκυρο.',

src/lang/en/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => 'The :attribute is not valid.',
2424
'phone-number' => 'The :attribute is not valid.',
2525
'port' => 'The :attribute is not valid.',
26+
'postal-code' => 'The :attribute is not valid.',
2627
'slash-end-of-string' => 'The :attribute is not valid.',
2728
'slug' => 'The :attribute is not valid.',
2829
'strong-password' => 'The :attribute is not valid.',

src/lang/es/validate.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
'odd-number' => ':attribute no es válido.',
2424
'phone-number' => ':attribute no es válido.',
2525
'port' => ':attribute no es válido.',
26+
'postal-code' => ':attribute no es válido.',
2627
'slash-end-of-string' => ':attribute no es válido.',
2728
'slug' => ':attribute no es válido.',
2829
'strong-password' => ':attribute no es válido.',

0 commit comments

Comments
 (0)