Index: trunk/extensions/Validator/Validator.class.php |
— | — | @@ -20,9 +20,6 @@ |
21 | 21 | * |
22 | 22 | * @author Jeroen De Dauw |
23 | 23 | * |
24 | | - * TODO: add dependency system |
25 | | - * * find out how to decompress dependency tree in an efficient way |
26 | | - * * handle params in the determined order and make meta data available for sucessive ones |
27 | 24 | * TODO: provide all original and inferred info about a parameter pair to the validation and formatting functions. |
28 | 25 | * this will allow for the special behaviour of the default parameter of display_points in Maps |
29 | 26 | * where the actual alias influences the handling |
— | — | @@ -466,7 +463,7 @@ |
467 | 464 | private function doCriteriaValidation( $validationFunction, $value, array $metaData, array $criteriaArgs ) { |
468 | 465 | // Call the validation function and store the result. |
469 | 466 | //var_dump($metaData);exit; |
470 | | - return call_user_func_array( $validationFunction, array_merge( array_merge( array( $value ), $metaData), $criteriaArgs ) ); |
| 467 | + return call_user_func_array( $validationFunction, array_merge( array_merge( array( $value ), array( $metaData ) ), $criteriaArgs ) ); |
471 | 468 | } |
472 | 469 | |
473 | 470 | /** |
Index: trunk/extensions/Validator/Validator_Functions.php |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | * |
33 | 33 | * @return boolean |
34 | 34 | */ |
35 | | - public static function in_range( $value, $lower = false, $upper = false ) { |
| 35 | + public static function in_range( $value, array $metaData, $lower = false, $upper = false ) { |
36 | 36 | if ( ! is_numeric( $value ) ) return false; |
37 | 37 | $value = (int)$value; |
38 | 38 | if ( $lower !== false && $value < $lower ) return false; |
— | — | @@ -46,7 +46,7 @@ |
47 | 47 | * |
48 | 48 | * @return boolean |
49 | 49 | */ |
50 | | - public static function not_empty( $value ) { |
| 50 | + public static function not_empty( $value, array $metaData ) { |
51 | 51 | return strlen( trim( $value ) ) > 0; |
52 | 52 | } |
53 | 53 | |
— | — | @@ -57,7 +57,7 @@ |
58 | 58 | * |
59 | 59 | * @return boolean |
60 | 60 | */ |
61 | | - public static function in_array( $value ) { |
| 61 | + public static function in_array( $value, array $metaData ) { |
62 | 62 | // TODO: It's possible the way the allowed values are passed here is quite inneficient... |
63 | 63 | $params = func_get_args(); |
64 | 64 | array_shift( $params ); // Ommit the value |
— | — | @@ -71,7 +71,7 @@ |
72 | 72 | * |
73 | 73 | * @return boolean |
74 | 74 | */ |
75 | | - public static function is_integer( $value ) { |
| 75 | + public static function is_integer( $value, array $metaData ) { |
76 | 76 | return ctype_digit( (string)$value ); |
77 | 77 | } |
78 | 78 | |
— | — | @@ -84,7 +84,7 @@ |
85 | 85 | * |
86 | 86 | * @return boolean |
87 | 87 | */ |
88 | | - public static function has_length( $value, $lower = false, $upper = false ) { |
| 88 | + public static function has_length( $value, array $metaData, $lower = false, $upper = false ) { |
89 | 89 | return self::in_range( strlen( $value ), $lower, $upper ); |
90 | 90 | } |
91 | 91 | |
— | — | @@ -97,7 +97,7 @@ |
98 | 98 | * |
99 | 99 | * @return boolean |
100 | 100 | */ |
101 | | - public static function has_item_count( array $values, $lower = false, $upper = false ) { |
| 101 | + public static function has_item_count( array $values, array $metaData, $lower = false, $upper = false ) { |
102 | 102 | return self::in_range( count( $values ), $lower, $upper ); |
103 | 103 | } |
104 | 104 | |
— | — | @@ -108,7 +108,7 @@ |
109 | 109 | * |
110 | 110 | * @return boolean |
111 | 111 | */ |
112 | | - public static function has_unique_items( array $values ) { |
| 112 | + public static function has_unique_items( array $values, array $metaData ) { |
113 | 113 | return count( $values ) == count( array_unique( $values ) ); |
114 | 114 | } |
115 | 115 | |
— | — | @@ -120,7 +120,7 @@ |
121 | 121 | * |
122 | 122 | * @return boolean |
123 | 123 | */ |
124 | | - public static function regex( $value, $pattern ) { |
| 124 | + public static function regex( $value, array $metaData, $pattern ) { |
125 | 125 | return (bool)preg_match( $pattern, $value ); |
126 | 126 | } |
127 | 127 | } |