r65675 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r65674‎ | r65675 | r65676 >
Date:22:11, 29 April 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Follow up to r65670
Modified paths:
  • /trunk/extensions/Validator/Validator.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/Validator.class.php
@@ -329,7 +329,10 @@
330330 }
331331
332332 /**
333 - * Valides the provided parameter by matching the value against the list and item criteria for the name.
 333+ * Valides the provided parameter.
 334+ *
 335+ * This method itself validates the list criteria, if any. After this the regular criteria
 336+ * are validated by calling the doItemValidation method.
334337 *
335338 * @param string $name
336339 *
@@ -348,7 +351,7 @@
349352 // Get the validation function. If there is no matching function, throw an exception.
350353 if ( array_key_exists( $criteriaName, self::$mListValidationFunctions ) ) {
351354 $validationFunction = self::$mListValidationFunctions[$criteriaName];
352 - $isValid = $this->doCriteriaValidation( $validationFunction, $value, array(), $criteriaArgs );
 355+ $isValid = $this->doCriteriaValidation( $validationFunction, $value, $this->mParameters[$name], $criteriaArgs );
353356
354357 // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated.
355358 if ( ! $isValid ) {
@@ -398,7 +401,7 @@
399402
400403 // Loop through all the items in the parameter value, and validate them.
401404 foreach ( $value as $item ) {
402 - $isValid = $this->doCriteriaValidation( $validationFunction, $item, array(), $criteriaArgs );
 405+ $isValid = $this->doCriteriaValidation( $validationFunction, $item, $this->mParameters[$name], $criteriaArgs );
403406 if ( $isValid ) {
404407 // If per item validation is on, store the valid items, so only these can be returned by Validator.
405408 if ( self::$perItemValidation ) $validItems[] = $item;
@@ -429,7 +432,7 @@
430433 }
431434 else {
432435 // Determine if the value is valid for single valued parameters.
433 - $isValid = $this->doCriteriaValidation( $validationFunction, $value, array(), $criteriaArgs );
 436+ $isValid = $this->doCriteriaValidation( $validationFunction, $value, $this->mParameters[$name], $criteriaArgs );
434437 }
435438
436439 // Add a new error when the validation failed, and break the loop if errors for one parameter should not be accumulated.
@@ -462,6 +465,7 @@
463466 */
464467 private function doCriteriaValidation( $validationFunction, $value, array $metaData, array $criteriaArgs ) {
465468 // Call the validation function and store the result.
 469+ //var_dump($metaData);exit;
466470 return call_user_func_array( $validationFunction, array_merge( array_merge( array( $value ), $metaData), $criteriaArgs ) );
467471 }
468472

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

Status & tagging log