Index: trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | * @see ParameterCriterion::validate |
28 | 28 | */ |
29 | 29 | public function validate( $value ) { |
30 | | - |
| 30 | + return is_numeric( $value ); |
31 | 31 | } |
32 | 32 | |
33 | 33 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php |
— | — | @@ -14,19 +14,32 @@ |
15 | 15 | class CriterionMatchesRegex extends ParameterCriterion { |
16 | 16 | |
17 | 17 | /** |
| 18 | + * The pattern to match against. |
| 19 | + * |
| 20 | + * @since 0.4 |
| 21 | + * |
| 22 | + * @var string |
| 23 | + */ |
| 24 | + protected $pattern; |
| 25 | + |
| 26 | + /** |
18 | 27 | * Constructor. |
19 | 28 | * |
| 29 | + * @param string $pattern |
| 30 | + * |
20 | 31 | * @since 0.4 |
21 | 32 | */ |
22 | | - public function __construct( ) { |
| 33 | + public function __construct( $pattern ) { |
23 | 34 | parent::__construct(); |
| 35 | + |
| 36 | + $this->pattern = $pattern; |
24 | 37 | } |
25 | 38 | |
26 | 39 | /** |
27 | 40 | * @see ParameterCriterion::validate |
28 | 41 | */ |
29 | 42 | public function validate( $value ) { |
30 | | - |
| 43 | + return (bool)preg_match( $this->pattern, $value ); |
31 | 44 | } |
32 | 45 | |
33 | 46 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * |
20 | 20 | * @since 0.4 |
21 | 21 | */ |
22 | | - public function __construct( ) { |
| 22 | + public function __construct() { |
23 | 23 | parent::__construct(); |
24 | 24 | } |
25 | 25 | |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | * @see ParameterCriterion::validate |
28 | 28 | */ |
29 | 29 | public function validate( $value ) { |
30 | | - |
| 30 | + return strlen( trim( $value ) ) > 0; |
31 | 31 | } |
32 | 32 | |
33 | 33 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | * |
20 | 20 | * @since 0.4 |
21 | 21 | */ |
22 | | - public function __construct( ) { |
| 22 | + public function __construct() { |
23 | 23 | parent::__construct(); |
24 | 24 | } |
25 | 25 | |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | * @see ParameterCriterion::validate |
28 | 28 | */ |
29 | 29 | public function validate( $value ) { |
30 | | - |
| 30 | + return preg_match( '/^\d+(\.\d+)?$/', $value ); |
31 | 31 | } |
32 | 32 | |
33 | 33 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php |
— | — | @@ -26,7 +26,7 @@ |
27 | 27 | * @see ParameterCriterion::validate |
28 | 28 | */ |
29 | 29 | public function validate( $value ) { |
30 | | - |
| 30 | + return ctype_digit( (string)$value ); |
31 | 31 | } |
32 | 32 | |
33 | 33 | } |
\ No newline at end of file |
Index: trunk/extensions/Validator/includes/ParameterCriterion.php |
— | — | @@ -20,6 +20,8 @@ |
21 | 21 | * @param string $value |
22 | 22 | * |
23 | 23 | * @since 0.4 |
| 24 | + * |
| 25 | + * @return boolean |
24 | 26 | */ |
25 | 27 | public abstract function validate( $value ); |
26 | 28 | |