Skip to content

Commit

Permalink
revert digits changes
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 26, 2022
1 parent 1383b5d commit c6d1a2d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 63 deletions.
22 changes: 1 addition & 21 deletions src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -564,18 +564,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];
}

Expand All @@ -593,15 +582,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];
}
Expand Down
42 changes: 0 additions & 42 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2272,30 +2272,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());
Expand All @@ -2314,24 +2290,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()
Expand Down

0 comments on commit c6d1a2d

Please sign in to comment.