Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Added some changes on iran phone validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Shahrokh Niakan committed Sep 28, 2016
1 parent 9e933b9 commit bb5b684
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/ValidationRules.php
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public function Less($attribute, $value, $parameters)
public function IranPhone($attribute, $value)
{

$this->status = preg_match('/^([1-9]{8})+$/', $value) ;
$this->status = preg_match('/^[2-9][0-9]{7}+$/', $value) ;

return ( $this->status ? true : false );

Expand Down
8 changes: 6 additions & 2 deletions tests/PersianValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,14 +444,18 @@ public function testLess()
public function testIranPhone()
{

$this->value = '7236445';
$this->value = '07236445';

$this->assertEquals(false, $this->PersianValidation->IranPhone($this->attribute, $this->value));

$this->value = '0217236445';
$this->value = '7236445';

$this->assertEquals(false, $this->PersianValidation->IranPhone($this->attribute, $this->value));

$this->value = '17236445';

$this->assertEquals(false, $this->PersianValidation->IranPhone($this->attribute, $this->value));

$this->value = '37236445';

$this->assertEquals(true, $this->PersianValidation->IranPhone($this->attribute, $this->value));
Expand Down

0 comments on commit bb5b684

Please sign in to comment.