Skip to content

Commit 6fb604f

Browse files
add test for between validation rule (#42596)
1 parent 7326882 commit 6fb604f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

tests/Validation/ValidationValidatorTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2389,6 +2389,24 @@ public function testValidateBetween()
23892389
$v = new Validator($trans, ['foo' => '123'], ['foo' => 'Numeric|Between:50,100']);
23902390
$this->assertFalse($v->passes());
23912391

2392+
// inclusive on min
2393+
$v = new Validator($trans, ['foo' => '123'], ['foo' => 'Numeric|Between:123,200']);
2394+
$this->assertTrue($v->passes());
2395+
2396+
// inclusive on max
2397+
$v = new Validator($trans, ['foo' => '123'], ['foo' => 'Numeric|Between:0,123']);
2398+
$this->assertTrue($v->passes());
2399+
2400+
// can work with float
2401+
$v = new Validator($trans, ['foo' => '0.02'], ['foo' => 'Numeric|Between:0.01,0.02']);
2402+
$this->assertTrue($v->passes());
2403+
2404+
$v = new Validator($trans, ['foo' => '0.02'], ['foo' => 'Numeric|Between:0.01,0.03']);
2405+
$this->assertTrue($v->passes());
2406+
2407+
$v = new Validator($trans, ['foo' => '0.001'], ['foo' => 'Numeric|Between:0.01,0.03']);
2408+
$this->assertFalse($v->passes());
2409+
23922410
$v = new Validator($trans, ['foo' => '3'], ['foo' => 'Numeric|Between:1,5']);
23932411
$this->assertTrue($v->passes());
23942412

0 commit comments

Comments
 (0)