Index: trunk/extensions/Validator/Validator.class.php |
— | — | @@ -56,6 +56,7 @@ |
57 | 57 | 'is_integer' => array( 'ValidatorFunctions', 'is_integer' ), |
58 | 58 | 'not_empty' => array( 'ValidatorFunctions', 'not_empty' ), |
59 | 59 | 'has_length' => array( 'ValidatorFunctions', 'has_length' ), |
| 60 | + 'regex' => array( 'ValidatorFunctions', 'regex' ), |
60 | 61 | ); |
61 | 62 | |
62 | 63 | /** |
Index: trunk/extensions/Validator/Validator_Functions.php |
— | — | @@ -110,4 +110,16 @@ |
111 | 111 | public static function has_unique_items( array $values ) { |
112 | 112 | return count($values) == count(array_unique($values)); |
113 | 113 | } |
| 114 | + |
| 115 | + /** |
| 116 | + * Returns the result of preg_match. |
| 117 | + * |
| 118 | + * @param string $value |
| 119 | + * @param string $pattern |
| 120 | + * |
| 121 | + * @return boolean |
| 122 | + */ |
| 123 | + public static function regex( $value, $pattern ) { |
| 124 | + return preg_match($pattern, $value); |
| 125 | + } |
114 | 126 | } |
Index: trunk/extensions/Validator/Validator_Manager.php |
— | — | @@ -81,7 +81,7 @@ |
82 | 82 | $msg = wfMsgExt( 'validator_list_error_empty_argument', array( 'parsemag' ), $error['name'] ); |
83 | 83 | break; |
84 | 84 | case 'in_range' : |
85 | | - $msg = wfMsgExt( 'validator_list_error_invalid_range', array( 'parsemag' ), $error['name'], $error['args'][0], $error['args'][1] ); |
| 85 | + $msg = wfMsgExt( 'validator_list_error_invalid_range', array( 'parsemag' ), $error['name'], '<b>' . $error['args'][0]. '</b>', '<b>' .$error['args'][1]. '</b>' ); |
86 | 86 | break; |
87 | 87 | case 'is_numeric' : |
88 | 88 | $msg = wfMsgExt( 'validator_list_error_must_be_number', array( 'parsemag' ), $error['name'] ); |
— | — | @@ -111,7 +111,7 @@ |
112 | 112 | $errors[] = wfMsgExt( 'validator_error_empty_argument', array( 'parsemag' ), $error['name'] ); |
113 | 113 | break; |
114 | 114 | case 'in_range' : |
115 | | - $errors[] = wfMsgExt( 'validator_error_invalid_range', array( 'parsemag' ), $error['name'], $error['args'][0], $error['args'][1] ); |
| 115 | + $errors[] = wfMsgExt( 'validator_error_invalid_range', array( 'parsemag' ), $error['name'], '<b>' . $error['args'][0]. '</b>', '<b>' .$error['args'][1]. '</b>' ); |
116 | 116 | break; |
117 | 117 | case 'is_numeric' : |
118 | 118 | $errors[] = wfMsgExt( 'validator_error_must_be_number', array( 'parsemag' ), $error['name'] ); |
— | — | @@ -124,7 +124,7 @@ |
125 | 125 | $errors[] = wfMsgExt( 'validator_error_accepts_only', array( 'parsemag' ), $error['name'], $itemsText, count( $error['args'] ) ); |
126 | 126 | break; |
127 | 127 | case 'invalid' : default : |
128 | | - $errors[] = wfMsgExt( 'validator_error_invalid_argument', array( 'parsemag' ), $error['value'], $error['name'] ); |
| 128 | + $errors[] = wfMsgExt( 'validator_error_invalid_argument', array( 'parsemag' ), '<b>' . $error['value'] . '</b>', $error['name'] ); |
129 | 129 | break; |
130 | 130 | } |
131 | 131 | } |
Index: trunk/extensions/Validator/Validator.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | die( 'Not an entry point.' ); |
26 | 26 | } |
27 | 27 | |
28 | | -define( 'Validator_VERSION', '0.2 a7' ); |
| 28 | +define( 'Validator_VERSION', '0.2 a8' ); |
29 | 29 | |
30 | 30 | // Constants indicating the strictness of the parameter validation. |
31 | 31 | define( 'Validator_ERRORS_NONE', 0 ); |