Index: trunk/extensions/Validator/includes/criteria/CriterionInRange.php |
— | — | @@ -13,14 +13,29 @@ |
14 | 14 | */ |
15 | 15 | class CriterionInRange extends ItemParameterCriterion { |
16 | 16 | |
| 17 | + /** |
| 18 | + * Lower bound of the range. Either a number or false, for no lower limit. |
| 19 | + * |
| 20 | + * @since 0.4 |
| 21 | + * |
| 22 | + * @var mixed |
| 23 | + */ |
17 | 24 | protected $lowerBound; |
| 25 | + |
| 26 | + /** |
| 27 | + * Upper bound of the range. Either a number or false, for no upper limit. |
| 28 | + * |
| 29 | + * @since 0.4 |
| 30 | + * |
| 31 | + * @var mixed |
| 32 | + */ |
18 | 33 | protected $upperBound; |
19 | 34 | |
20 | 35 | /** |
21 | 36 | * Constructor. |
22 | 37 | * |
23 | | - * @param integer $lowerBound |
24 | | - * @param integer $upperBound |
| 38 | + * @param mixed $lowerBound |
| 39 | + * @param mixed $upperBound |
25 | 40 | * |
26 | 41 | * @since 0.4 |
27 | 42 | */ |
— | — | @@ -35,13 +50,14 @@ |
36 | 51 | * @see ItemParameterCriterion::validate |
37 | 52 | */ |
38 | 53 | protected function doValidation( $value ) { |
39 | | - if ( ! is_numeric( $value ) ) { |
| 54 | + if ( !is_numeric( $value ) ) { |
40 | 55 | return false; |
41 | 56 | } |
42 | 57 | |
43 | 58 | $value = (int)$value; |
44 | 59 | |
45 | | - return $value <= $this->upperBound && $value >= $this->lowerBound; |
| 60 | + return ( $this->upperBound === false || $value <= $this->upperBound ) |
| 61 | + && ( $this->lowerBound === false || $value >= $this->lowerBound ); |
46 | 62 | } |
47 | 63 | |
48 | 64 | /** |