r72418 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72417‎ | r72418 | r72419 >
Date:13:05, 5 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Implemented CriterionInArray validation
Modified paths:
  • /trunk/extensions/Validator/includes/criteria/CriterionHasLength.php (modified) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionInArray.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
@@ -19,6 +19,9 @@
2020 /**
2121 * Constructor.
2222 *
 23+ * @param integer $lowerBound
 24+ * @param mixed $upperBound
 25+ *
2326 * @since 0.4
2427 */
2528 public function __construct( $lowerBound, $upperBound = false ) {
Index: trunk/extensions/Validator/includes/criteria/CriterionInArray.php
@@ -14,19 +14,32 @@
1515 class CriterionInArray extends ParameterCriterion {
1616
1717 /**
 18+ * List of allowed values.
 19+ *
 20+ * @since 0.4
 21+ *
 22+ * @var array
 23+ */
 24+ protected $allowedValues;
 25+
 26+ /**
1827 * Constructor.
1928 *
 29+ * @param mixed $allowedValues
 30+ *
2031 * @since 0.4
2132 */
22 - public function __construct( ) {
 33+ public function __construct( $allowedValues ) {
2334 parent::__construct();
 35+
 36+ $this->allowedValues = (array)$allowedValues;
2437 }
2538
2639 /**
2740 * @see ParameterCriterion::validate
2841 */
2942 public function validate( $value ) {
30 -
 43+ return in_array( $value, $this->allowedValues );
3144 }
3245
3346 }
\ No newline at end of file

Status & tagging log