From c113768dbd47de7466d703108eaf8155916d5666 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Thu, 26 May 2022 09:03:27 -0500 Subject: [PATCH] revert digits changes --- .../Concerns/ValidatesAttributes.php | 22 +--------- tests/Validation/ValidationValidatorTest.php | 42 ------------------- 2 files changed, 1 insertion(+), 63 deletions(-) diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php index 1f5ad956a486..9a4ca19b5431 100644 --- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php +++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php @@ -563,18 +563,7 @@ public function validateDigits($attribute, $value, $parameters) { $this->requireParameterCount(1, $parameters, 'digits'); - $length = strlen((string) $value); - - if (((string) $value) === '.') { - return false; - } - - // Make sure there is not more than one dot... - if (($length - strlen(str_replace('.', '', (string) $value))) > 1) { - return false; - } - - return ! preg_match('/[^0-9.]/', $value) + return ! preg_match('/[^0-9]/', $value) && strlen((string) $value) == $parameters[0]; } @@ -592,15 +581,6 @@ public function validateDigitsBetween($attribute, $value, $parameters) $length = strlen((string) $value); - if (((string) $value) === '.') { - return false; - } - - // Make sure there is not more than one dot... - if (($length - strlen(str_replace('.', '', (string) $value))) > 1) { - return false; - } - return ! preg_match('/[^0-9.]/', $value) && $length >= $parameters[0] && $length <= $parameters[1]; } diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index 2aa625e80b17..bdfc0977bbe9 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -2325,30 +2325,6 @@ public function testValidateDigits() $v = new Validator($trans, ['foo' => '2e7'], ['foo' => 'Digits:3']); $this->assertTrue($v->fails()); - $v = new Validator($trans, ['foo' => '1.2'], ['foo' => 'digits:3']); - $this->assertTrue($v->passes()); - - $v = new Validator($trans, ['foo' => '0.9876'], ['foo' => 'digits:5']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '1..2'], ['foo' => 'digits:4']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '123.456.789'], ['foo' => 'digits:10']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '...'], ['foo' => 'digits:3']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '.'], ['foo' => 'digits:1']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '.2'], ['foo' => 'digits:2']); - $this->assertTrue($v->passes()); - - $v = new Validator($trans, ['foo' => '2.'], ['foo' => 'digits:2']); - $this->assertTrue($v->passes()); - $trans = $this->getIlluminateArrayTranslator(); $v = new Validator($trans, ['foo' => '12345'], ['foo' => 'digits_between:1,6']); $this->assertTrue($v->passes()); @@ -2367,24 +2343,6 @@ public function testValidateDigits() $v = new Validator($trans, ['foo' => '0.9876'], ['foo' => 'digits_between:1,5']); $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '1..2'], ['foo' => 'digits_between:1,10']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '123.456.789'], ['foo' => 'digits_between:1,10']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '...'], ['foo' => 'digits_between:1,10']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '.'], ['foo' => 'digits_between:1,10']); - $this->assertTrue($v->fails()); - - $v = new Validator($trans, ['foo' => '.2'], ['foo' => 'digits_between:0,10']); - $this->assertTrue($v->passes()); - - $v = new Validator($trans, ['foo' => '2.'], ['foo' => 'digits_between:1,10']); - $this->assertTrue($v->passes()); } public function testValidateSize()