Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Rules/Between.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ public function check($value)

$min = (int) $this->parameter('min');
$max = (int) $this->parameter('max');
if (is_int($value)) {

if (is_int($value) || is_float($value)) {
return $value >= $min AND $value <= $max;
} elseif(is_string($value)) {
return mb_strlen($value, 'UTF-8') >= $min AND mb_strlen($value, 'UTF-8') <= $max;
Expand Down
2 changes: 2 additions & 0 deletions tests/Rules/BetweenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function testValids()
$this->assertTrue($this->rule->fillParameters([6, 10])->check('футбол'));
$this->assertTrue($this->rule->fillParameters([2, 3])->check([1,2,3]));
$this->assertTrue($this->rule->fillParameters([100, 150])->check(123));
$this->assertTrue($this->rule->fillParameters([100, 150])->check(123.4));
}

public function testInvalids()
Expand All @@ -24,6 +25,7 @@ public function testInvalids()
$this->assertFalse($this->rule->fillParameters([2, 5])->check('футбол'));
$this->assertFalse($this->rule->fillParameters([4, 6])->check([1,2,3]));
$this->assertFalse($this->rule->fillParameters([50, 100])->check(123));
$this->assertFalse($this->rule->fillParameters([50, 100])->check(123.4));
}

}