From bb5b684c7cae3e6a700821a8a226b10a950727ee Mon Sep 17 00:00:00 2001 From: Shahrokh Niakan Date: Wed, 28 Sep 2016 14:52:48 +0330 Subject: [PATCH] Added some changes on iran phone validation --- src/ValidationRules.php | 2 +- tests/PersianValidationTest.php | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ValidationRules.php b/src/ValidationRules.php index 6859c91..ec32f47 100644 --- a/src/ValidationRules.php +++ b/src/ValidationRules.php @@ -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 ); diff --git a/tests/PersianValidationTest.php b/tests/PersianValidationTest.php index cc7c16f..f41ba0a 100644 --- a/tests/PersianValidationTest.php +++ b/tests/PersianValidationTest.php @@ -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));