r72416 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r72415‎ | r72416 | r72417 >
Date:12:54, 5 September 2010
Author:jeroendedauw
Status:deferred
Tags:
Comment:
Changes for 0.4 - added parameter criteria classes
Modified paths:
  • /trunk/extensions/Validator/Validator.php (modified) (history)
  • /trunk/extensions/Validator/includes/ParameterCriterion.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionHasLength.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionInArray.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionInRange.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php (added) (history)
  • /trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php (added) (history)

Diff [purge]

Index: trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must have a certain length.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionHasLength.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionHasLength extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must be a number.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionIsNumeric.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionIsNumeric extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must match a regex.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionMatchesRegex.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionMatchesRegex extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must not be empty (empty being a string with 0 lentgh).
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionNotEmpty.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionNotEmpty extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must be a float.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionIsFloat.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionIsFloat extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/criteria/CriterionInRange.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must be in a certain range.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionInRange.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionInRange extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionInRange.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/criteria/CriterionInArray.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must be in an array.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionInArray.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionInArray extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionInArray.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php
@@ -0,0 +1,32 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion stating that the value must be an integer.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file CriterionIsInteger.php
 10+ * @ingroup Validator
 11+ * @ingroup Criteria
 12+ *
 13+ * @author Jeroen De Dauw
 14+ */
 15+class CriterionIsInteger extends ParameterCriterion {
 16+
 17+ /**
 18+ * Constructor.
 19+ *
 20+ * @since 0.4
 21+ */
 22+ public function __construct( ) {
 23+ parent::__construct();
 24+ }
 25+
 26+ /**
 27+ * @see ParameterCriterion::validate
 28+ */
 29+ public function validate( $value ) {
 30+
 31+ }
 32+
 33+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php
___________________________________________________________________
Added: svn:eol-style
134 + native
Index: trunk/extensions/Validator/includes/ParameterCriterion.php
@@ -0,0 +1,54 @@
 2+<?php
 3+
 4+/**
 5+ * Parameter criterion definition class.
 6+ *
 7+ * @since 0.4
 8+ *
 9+ * @file ParameterCriterion.php
 10+ * @ingroup Validator
 11+ *
 12+ * @author Jeroen De Dauw
 13+ */
 14+abstract class ParameterCriterion {
 15+
 16+ public static $criteria = array();
 17+
 18+ /**
 19+ * Validate a value against the criterion.
 20+ *
 21+ * @param string $value
 22+ *
 23+ * @since 0.4
 24+ */
 25+ public abstract function validate( $value );
 26+
 27+ /**
 28+ * Returns a new instance of ParameterCriterion by converting an element of a Validator 3.x-style criteria array definition.
 29+ * Note: this method is for backward compatibility and should not be used in new code.
 30+ *
 31+ * @since 0.4
 32+ *
 33+ * @param string $name
 34+ * @param array $definition
 35+ *
 36+ * @return ParameterCriterion
 37+ */
 38+ public static function newFromArray( $name, array $definition ) {
 39+
 40+ }
 41+
 42+ /**
 43+ * Constructor.
 44+ *
 45+ * @since 0.4
 46+ */
 47+ public function __construct() {
 48+
 49+ }
 50+
 51+ protected function getValidationFunction() {
 52+
 53+ }
 54+
 55+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/ParameterCriterion.php
___________________________________________________________________
Added: svn:eol-style
156 + native
Index: trunk/extensions/Validator/Validator.php
@@ -51,7 +51,7 @@
5252 wfLoadExtensionMessages( 'Validator' );
5353 }
5454
55 -// Autoload the general classes.
 55+// Autoload the classes.
5656 $incDir = dirname( __FILE__ ) . '/includes/';
5757 $wgAutoloadClasses['ListParameter'] = $incDir . 'ListParameter.php';
5858 $wgAutoloadClasses['Parameter'] = $incDir . 'Parameter.php';
@@ -63,6 +63,16 @@
6464 $wgAutoloadClasses['ValidationManager'] = $incDir . 'ValidationManager.php'; // TODO: remove
6565 $wgAutoloadClasses['ValidatorError'] = $incDir . 'Validator_Error.php';
6666 $wgAutoloadClasses['ValidatorErrorHandler'] = $incDir . 'Validator_ErrorHandler.php';
 67+
 68+$wgAutoloadClasses['CriterionHasLength'] = $incDir . 'criteria/CriterionHasLength.php';
 69+$wgAutoloadClasses['CriterionInArray'] = $incDir . 'criteria/CriterionInArray.php';
 70+$wgAutoloadClasses['CriterionInRange'] = $incDir . 'criteria/CriterionInRange.php';
 71+$wgAutoloadClasses['CriterionIsFloat'] = $incDir . 'criteria/CriterionIsFloat.php';
 72+$wgAutoloadClasses['CriterionIsInteger'] = $incDir . 'criteria/CriterionIsInteger.php';
 73+$wgAutoloadClasses['CriterionIsNumeric'] = $incDir . 'criteria/CriterionIsNumeric.php';
 74+$wgAutoloadClasses['CriterionMatchesRegex'] = $incDir . 'criteria/CriterionMatchesRegex.php';
 75+$wgAutoloadClasses['CriterionNotEmpty'] = $incDir . 'criteria/CriterionNotEmpty.php';
 76+
6777 $wgAutoloadClasses['ValidatorListErrors'] = $incDir . 'parserHooks/Validator_ListErrors.php';
6878 unset( $incDir );
6979

Status & tagging log