Skip to content

Commit 36eff92

Browse files
authored
Fix digits_between with fractions (#40278)
1 parent 0d87522 commit 36eff92

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ public function validateDigitsBetween($attribute, $value, $parameters)
486486

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

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

tests/Validation/ValidationValidatorTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1767,6 +1767,12 @@ public function testValidateDigits()
17671767

17681768
$v = new Validator($trans, ['foo' => '+12.3'], ['foo' => 'digits_between:1,6']);
17691769
$this->assertFalse($v->passes());
1770+
1771+
$v = new Validator($trans, ['foo' => '1.2'], ['foo' => 'digits_between:1,10']);
1772+
$this->assertTrue($v->passes());
1773+
1774+
$v = new Validator($trans, ['foo' => '0.9876'], ['foo' => 'digits_between:1,5']);
1775+
$this->assertTrue($v->fails());
17701776
}
17711777

17721778
public function testValidateSize()

0 commit comments

Comments
 (0)