Skip to content

Commit c113768

Browse files
committed
revert digits changes
1 parent a4723ec commit c113768

File tree

2 files changed

+1
-63
lines changed

2 files changed

+1
-63
lines changed

src/Illuminate/Validation/Concerns/ValidatesAttributes.php

+1-21
Original file line numberDiff line numberDiff line change
@@ -563,18 +563,7 @@ public function validateDigits($attribute, $value, $parameters)
563563
{
564564
$this->requireParameterCount(1, $parameters, 'digits');
565565

566-
$length = strlen((string) $value);
567-
568-
if (((string) $value) === '.') {
569-
return false;
570-
}
571-
572-
// Make sure there is not more than one dot...
573-
if (($length - strlen(str_replace('.', '', (string) $value))) > 1) {
574-
return false;
575-
}
576-
577-
return ! preg_match('/[^0-9.]/', $value)
566+
return ! preg_match('/[^0-9]/', $value)
578567
&& strlen((string) $value) == $parameters[0];
579568
}
580569

@@ -592,15 +581,6 @@ public function validateDigitsBetween($attribute, $value, $parameters)
592581

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

595-
if (((string) $value) === '.') {
596-
return false;
597-
}
598-
599-
// Make sure there is not more than one dot...
600-
if (($length - strlen(str_replace('.', '', (string) $value))) > 1) {
601-
return false;
602-
}
603-
604584
return ! preg_match('/[^0-9.]/', $value)
605585
&& $length >= $parameters[0] && $length <= $parameters[1];
606586
}

tests/Validation/ValidationValidatorTest.php

-42
Original file line numberDiff line numberDiff line change
@@ -2325,30 +2325,6 @@ public function testValidateDigits()
23252325
$v = new Validator($trans, ['foo' => '2e7'], ['foo' => 'Digits:3']);
23262326
$this->assertTrue($v->fails());
23272327

2328-
$v = new Validator($trans, ['foo' => '1.2'], ['foo' => 'digits:3']);
2329-
$this->assertTrue($v->passes());
2330-
2331-
$v = new Validator($trans, ['foo' => '0.9876'], ['foo' => 'digits:5']);
2332-
$this->assertTrue($v->fails());
2333-
2334-
$v = new Validator($trans, ['foo' => '1..2'], ['foo' => 'digits:4']);
2335-
$this->assertTrue($v->fails());
2336-
2337-
$v = new Validator($trans, ['foo' => '123.456.789'], ['foo' => 'digits:10']);
2338-
$this->assertTrue($v->fails());
2339-
2340-
$v = new Validator($trans, ['foo' => '...'], ['foo' => 'digits:3']);
2341-
$this->assertTrue($v->fails());
2342-
2343-
$v = new Validator($trans, ['foo' => '.'], ['foo' => 'digits:1']);
2344-
$this->assertTrue($v->fails());
2345-
2346-
$v = new Validator($trans, ['foo' => '.2'], ['foo' => 'digits:2']);
2347-
$this->assertTrue($v->passes());
2348-
2349-
$v = new Validator($trans, ['foo' => '2.'], ['foo' => 'digits:2']);
2350-
$this->assertTrue($v->passes());
2351-
23522328
$trans = $this->getIlluminateArrayTranslator();
23532329
$v = new Validator($trans, ['foo' => '12345'], ['foo' => 'digits_between:1,6']);
23542330
$this->assertTrue($v->passes());
@@ -2367,24 +2343,6 @@ public function testValidateDigits()
23672343

23682344
$v = new Validator($trans, ['foo' => '0.9876'], ['foo' => 'digits_between:1,5']);
23692345
$this->assertTrue($v->fails());
2370-
2371-
$v = new Validator($trans, ['foo' => '1..2'], ['foo' => 'digits_between:1,10']);
2372-
$this->assertTrue($v->fails());
2373-
2374-
$v = new Validator($trans, ['foo' => '123.456.789'], ['foo' => 'digits_between:1,10']);
2375-
$this->assertTrue($v->fails());
2376-
2377-
$v = new Validator($trans, ['foo' => '...'], ['foo' => 'digits_between:1,10']);
2378-
$this->assertTrue($v->fails());
2379-
2380-
$v = new Validator($trans, ['foo' => '.'], ['foo' => 'digits_between:1,10']);
2381-
$this->assertTrue($v->fails());
2382-
2383-
$v = new Validator($trans, ['foo' => '.2'], ['foo' => 'digits_between:0,10']);
2384-
$this->assertTrue($v->passes());
2385-
2386-
$v = new Validator($trans, ['foo' => '2.'], ['foo' => 'digits_between:1,10']);
2387-
$this->assertTrue($v->passes());
23882346
}
23892347

23902348
public function testValidateSize()

0 commit comments

Comments
 (0)