Bug Report #4685

Cannot ignore steps check in Valid::range() rule

Added by Ivan Brotkin almost 2 years ago. Updated almost 2 years ago.

Status:ClosedStart date:01/11/2013
Priority:LowDue date:
Assignee:Jeremy Bush% Done:

0%

Category:Core
Target version:3.3.1
Resolution:invalid Points:1

Description

Kohana v3.3 has a new param - $step, which allows to define an increment size. But there is no way to skip this check and use it like Valid::range() from 3.0-3.2.

I think this code:

if ( ! $step)
{
// Default to steps of 1
$step = 1;
}

should be like this:

if ($step === FALSE)
{
// dont check for steps
return TRUE;
}
elseif (empty($step)) {
// Default to steps of 1
$step = 1;
}

History

#1 Updated by Jeremy Bush almost 2 years ago

  • Status changed from New to Assigned
  • Priority changed from Normal to Low

This isn't correct. Step of 1 keeps the old behavior. It certainly shouldn't return TRUE if step is NULL. $step is there so you can check things like even or odd numbers in a range. With your change, it seems like Valid::range(1, 2, 3) would return TRUE.

#2 Updated by Jeremy Bush almost 2 years ago

We have tests for this method as well, which all pass: https://github.com/kohana/core/blob/3.3/master/tests/kohana/ValidTest.php#L846

#3 Updated by Ivan Brotkin almost 2 years ago

Valid::range(1, 2, 3) fails before step checking :)

Anyway, you are right about this rule. Its my mistake while checking it with float values. Im sorry for wasting your time.

#4 Updated by Jeremy Bush almost 2 years ago

  • Status changed from Assigned to Closed
  • Resolution set to invalid

Yeah, this method is meant to be used with integers, not floats (although I would expect it to work with those as well)

Also available in: Atom PDF