r65713 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65712‎ | r65713 | r65714 >
Date:19:50, 30 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Fixed bug 23356. Follow up to r65670.
Modified paths:
  • /trunk/extensions/Validator/Validator.class.php (modified) (history)
  • /trunk/extensions/Validator/Validator_Functions.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/Validator.class.php
@@ -20,9 +20,6 @@
2121 *
2222 * @author Jeroen De Dauw
2323 *
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
2724 * TODO: provide all original and inferred info about a parameter pair to the validation and formatting functions.
2825 * this will allow for the special behaviour of the default parameter of display_points in Maps
2926 * where the actual alias influences the handling
@@ -466,7 +463,7 @@
467464 private function doCriteriaValidation( $validationFunction, $value, array $metaData, array $criteriaArgs ) {
468465 // Call the validation function and store the result.
469466 //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 ) );
471468 }
472469
473470 /**
Index: trunk/extensions/Validator/Validator_Functions.php
@@ -31,7 +31,7 @@
3232 *
3333 * @return boolean
3434 */
35 - public static function in_range( $value, $lower = false, $upper = false ) {
 35+ public static function in_range( $value, array $metaData, $lower = false, $upper = false ) {
3636 if ( ! is_numeric( $value ) ) return false;
3737 $value = (int)$value;
3838 if ( $lower !== false && $value < $lower ) return false;
@@ -46,7 +46,7 @@
4747 *
4848 * @return boolean
4949 */
50 - public static function not_empty( $value ) {
 50+ public static function not_empty( $value, array $metaData ) {
5151 return strlen( trim( $value ) ) > 0;
5252 }
5353
@@ -57,7 +57,7 @@
5858 *
5959 * @return boolean
6060 */
61 - public static function in_array( $value ) {
 61+ public static function in_array( $value, array $metaData ) {
6262 // TODO: It's possible the way the allowed values are passed here is quite inneficient...
6363 $params = func_get_args();
6464 array_shift( $params ); // Ommit the value
@@ -71,7 +71,7 @@
7272 *
7373 * @return boolean
7474 */
75 - public static function is_integer( $value ) {
 75+ public static function is_integer( $value, array $metaData ) {
7676 return ctype_digit( (string)$value );
7777 }
7878
@@ -84,7 +84,7 @@
8585 *
8686 * @return boolean
8787 */
88 - public static function has_length( $value, $lower = false, $upper = false ) {
 88+ public static function has_length( $value, array $metaData, $lower = false, $upper = false ) {
8989 return self::in_range( strlen( $value ), $lower, $upper );
9090 }
9191
@@ -97,7 +97,7 @@
9898 *
9999 * @return boolean
100100 */
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 ) {
102102 return self::in_range( count( $values ), $lower, $upper );
103103 }
104104
@@ -108,7 +108,7 @@
109109 *
110110 * @return boolean
111111 */
112 - public static function has_unique_items( array $values ) {
 112+ public static function has_unique_items( array $values, array $metaData ) {
113113 return count( $values ) == count( array_unique( $values ) );
114114 }
115115
@@ -120,7 +120,7 @@
121121 *
122122 * @return boolean
123123 */
124 - public static function regex( $value, $pattern ) {
 124+ public static function regex( $value, array $metaData, $pattern ) {
125125 return (bool)preg_match( $pattern, $value );
126126 }
127127 }

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r65670CHanges for 0.3 - Partially added dependency handling and support for by meta...jeroendedauw21:32, 29 April 2010
r65712Fixed bug 23356. Follow up to r65670.jeroendedauw19:50, 30 April 2010

Status & tagging log