http://www.mediawiki.org/wiki/Special:Code/MediaWiki/72417
Revision: 72417
Author: jeroendedauw
Date: 2010-09-05 13:03:36 +0000 (Sun, 05 Sep 2010)
Log Message:
-----------
Implemented CriterionHasLength validation
Modified Paths:
--------------
trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
Modified: trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
===================================================================
--- trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
2010-09-05 12:54:33 UTC (rev 72416)
+++ trunk/extensions/Validator/includes/criteria/CriterionHasLength.php
2010-09-05 13:03:36 UTC (rev 72417)
@@ -13,20 +13,31 @@
*/
class CriterionHasLength extends ParameterCriterion {
+ protected $lowerBound;
+ protected $upperBound;
+
/**
* Constructor.
*
* @since 0.4
*/
- public function __construct( ) {
+ public function __construct( $lowerBound, $upperBound = false ) {
parent::__construct();
+
+ $this->lowerBound = $lowerBound;
+ $this->upperBound = $upperBound === false ? $lowerBound :
$upperBound;
}
/**
* @see ParameterCriterion::validate
*/
public function validate( $value ) {
+ $strlen = strlen( $value );
+ if ( $strlen > $this->upperBound ) return false;
+ if ( $strlen < $this->lowerBound ) return false;
+
+ return true;
}
}
\ No newline at end of file
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs