Index: trunk/extensions/Validator/test/ValidatorCriteriaTests.php |
— | — | @@ -80,11 +80,13 @@ |
81 | 81 | array( false, '4.2', Parameter::TYPE_FLOAT, 42, 42 ), |
82 | 82 | array( true, '4.2', Parameter::TYPE_FLOAT, 4.2, 4.2 ), |
83 | 83 | array( true, '4.2', Parameter::TYPE_FLOAT, 0, 9 ), |
| 84 | + array( true, '42', Parameter::TYPE_FLOAT, 0, 99 ), |
| 85 | + array( false, '42', Parameter::TYPE_FLOAT, 0, 9 ), |
84 | 86 | ); |
85 | 87 | |
86 | 88 | foreach ( $tests as $test ) { |
87 | 89 | $c = new CriterionInRange( $test[3], $test[4] ); |
88 | | - $p = new Parameter( 'test' ); |
| 90 | + $p = new Parameter( 'test', $test[2] ); |
89 | 91 | $p->setUserValue( 'test', $test[1] ); |
90 | 92 | $this->assertEquals( |
91 | 93 | $test[0], |
— | — | @@ -93,5 +95,5 @@ |
94 | 96 | ); |
95 | 97 | } |
96 | 98 | } |
97 | | - |
| 99 | + |
98 | 100 | } |
Index: trunk/extensions/Validator/includes/criteria/CriterionInRange.php |
— | — | @@ -54,7 +54,16 @@ |
55 | 55 | return false; |
56 | 56 | } |
57 | 57 | |
58 | | - $value = (float)$value; |
| 58 | + switch( $parameter->getType() ) { |
| 59 | + case Parameter::TYPE_INTEGER: |
| 60 | + $value = (int)$value; |
| 61 | + break; |
| 62 | + case Parameter::TYPE_FLOAT: |
| 63 | + $value = (float)$value; |
| 64 | + break; |
| 65 | + default: |
| 66 | + return false; |
| 67 | + } |
59 | 68 | |
60 | 69 | return ( $this->upperBound === false || $value <= $this->upperBound ) |
61 | 70 | && ( $this->lowerBound === false || $value >= $this->lowerBound ); |