Skip to content

Commit

Permalink
Fix digits_between with fractions (#40278)
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints authored Jan 6, 2022
1 parent 0d87522 commit 36eff92
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Validation/Concerns/ValidatesAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public function validateDigitsBetween($attribute, $value, $parameters)

$length = strlen((string) $value);

return ! preg_match('/[^0-9]/', $value)
return ! preg_match('/[^0-9.]/', $value)
&& $length >= $parameters[0] && $length <= $parameters[1];
}

Expand Down
6 changes: 6 additions & 0 deletions tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,12 @@ public function testValidateDigits()

$v = new Validator($trans, ['foo' => '+12.3'], ['foo' => 'digits_between:1,6']);
$this->assertFalse($v->passes());

$v = new Validator($trans, ['foo' => '1.2'], ['foo' => 'digits_between:1,10']);
$this->assertTrue($v->passes());

$v = new Validator($trans, ['foo' => '0.9876'], ['foo' => 'digits_between:1,5']);
$this->assertTrue($v->fails());
}

public function testValidateSize()
Expand Down

0 comments on commit 36eff92

Please sign in to comment.