http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72416
Revision: 72416
Author: jeroendedauw
Date: 2010-09-05 12:54:33 +0000 (Sun, 05 Sep 2010)
Log Message:
-----------
Changes for 0.4 - added parameter criteria classes
Modified Paths:
--------------
trunk/extensions/Validator/Validator.php
Added Paths:
-----------
trunk/extensions/Validator/includes/ParameterCriterion.php
trunk/extensions/Validator/includes/criteria/
trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
trunk/extensions/Validator/includes/criteria/CriterionInArray.php
trunk/extensions/Validator/includes/criteria/CriterionInRange.php
trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php
trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php
trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php
trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php
trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php
Modified: trunk/extensions/Validator/Validator.php
===================================================================
--- trunk/extensions/Validator/Validator.php 2010-09-05 12:52:35 UTC (rev
72415)
+++ trunk/extensions/Validator/Validator.php 2010-09-05 12:54:33 UTC (rev
72416)
@@ -51,7 +51,7 @@
wfLoadExtensionMessages( 'Validator' );
}
-// Autoload the general classes.
+// Autoload the classes.
$incDir = dirname( __FILE__ ) . '/includes/';
$wgAutoloadClasses['ListParameter'] = $incDir . 'ListParameter.php';
$wgAutoloadClasses['Parameter'] = $incDir .
'Parameter.php';
@@ -63,6 +63,16 @@
$wgAutoloadClasses['ValidationManager'] = $incDir .
'ValidationManager.php'; // TODO: remove
$wgAutoloadClasses['ValidatorError'] = $incDir .
'Validator_Error.php';
$wgAutoloadClasses['ValidatorErrorHandler'] = $incDir .
'Validator_ErrorHandler.php';
+
+$wgAutoloadClasses['CriterionHasLength'] = $incDir .
'criteria/CriterionHasLength.php';
+$wgAutoloadClasses['CriterionInArray'] = $incDir .
'criteria/CriterionInArray.php';
+$wgAutoloadClasses['CriterionInRange'] = $incDir .
'criteria/CriterionInRange.php';
+$wgAutoloadClasses['CriterionIsFloat'] = $incDir .
'criteria/CriterionIsFloat.php';
+$wgAutoloadClasses['CriterionIsInteger'] = $incDir .
'criteria/CriterionIsInteger.php';
+$wgAutoloadClasses['CriterionIsNumeric'] = $incDir .
'criteria/CriterionIsNumeric.php';
+$wgAutoloadClasses['CriterionMatchesRegex'] = $incDir .
'criteria/CriterionMatchesRegex.php';
+$wgAutoloadClasses['CriterionNotEmpty'] = $incDir .
'criteria/CriterionNotEmpty.php';
+
$wgAutoloadClasses['ValidatorListErrors'] = $incDir .
'parserHooks/Validator_ListErrors.php';
unset( $incDir );
Added: trunk/extensions/Validator/includes/ParameterCriterion.php
===================================================================
--- trunk/extensions/Validator/includes/ParameterCriterion.php
(rev 0)
+++ trunk/extensions/Validator/includes/ParameterCriterion.php 2010-09-05
12:54:33 UTC (rev 72416)
@@ -0,0 +1,54 @@
+<?php
+
+/**
+ * Parameter criterion definition class.
+ *
+ * @since 0.4
+ *
+ * @file ParameterCriterion.php
+ * @ingroup Validator
+ *
+ * @author Jeroen De Dauw
+ */
+abstract class ParameterCriterion {
+
+ public static $criteria = array();
+
+ /**
+ * Validate a value against the criterion.
+ *
+ * @param string $value
+ *
+ * @since 0.4
+ */
+ public abstract function validate( $value );
+
+ /**
+ * Returns a new instance of ParameterCriterion by converting an
element of a Validator 3.x-style criteria array definition.
+ * Note: this method is for backward compatibility and should not be
used in new code.
+ *
+ * @since 0.4
+ *
+ * @param string $name
+ * @param array $definition
+ *
+ * @return ParameterCriterion
+ */
+ public static function newFromArray( $name, array $definition ) {
+
+ }
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct() {
+
+ }
+
+ protected function getValidationFunction() {
+
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/extensions/Validator/includes/ParameterCriterion.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must have a certain length.
+ *
+ * @since 0.4
+ *
+ * @file CriterionHasLength.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionHasLength extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionInArray.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionInArray.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionInArray.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must be in an array.
+ *
+ * @since 0.4
+ *
+ * @file CriterionInArray.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionInArray extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionInArray.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionInRange.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionInRange.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionInRange.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must be in a certain range.
+ *
+ * @since 0.4
+ *
+ * @file CriterionInRange.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionInRange extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionInRange.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must be a float.
+ *
+ * @since 0.4
+ *
+ * @file CriterionIsFloat.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionIsFloat extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionIsFloat.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must be an integer.
+ *
+ * @since 0.4
+ *
+ * @file CriterionIsInteger.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionIsInteger extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionIsInteger.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must be a number.
+ *
+ * @since 0.4
+ *
+ * @file CriterionIsNumeric.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionIsNumeric extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionIsNumeric.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must match a regex.
+ *
+ * @since 0.4
+ *
+ * @file CriterionMatchesRegex.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionMatchesRegex extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionMatchesRegex.php
___________________________________________________________________
Added: svn:eol-style
+ native
Added: trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php
(rev 0)
+++ trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php
2010-09-05 12:54:33 UTC (rev 72416)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Parameter criterion stating that the value must not be empty (empty being a
string with 0 lentgh).
+ *
+ * @since 0.4
+ *
+ * @file CriterionNotEmpty.php
+ * @ingroup Validator
+ * @ingroup Criteria
+ *
+ * @author Jeroen De Dauw
+ */
+class CriterionNotEmpty extends ParameterCriterion {
+
+ /**
+ * Constructor.
+ *
+ * @since 0.4
+ */
+ public function __construct( ) {
+ parent::__construct();
+ }
+
+ /**
+ * @see ParameterCriterion::validate
+ */
+ public function validate( $value ) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/extensions/Validator/includes/criteria/CriterionNotEmpty.php
___________________________________________________________________
Added: svn:eol-style
+ native
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs