--- a/busui/owa/plugins/validations/stringLength.php +++ b/busui/owa/plugins/validations/stringLength.php @@ -1,1 +1,86 @@ - + + * @copyright Copyright © 2006 Peter Adams + * @license http://www.gnu.org/copyleft/gpl.html GPL v2.0 + * @category owa + * @package owa + * @version $Revision$ + * @since owa 1.0.0 + */ + + class owa_stringLengthValidation extends owa_validation { + + function __construct() { + + return parent::__construct(); + } + + function validate() { + + $value = $this->getValues(); + $length = $this->getConfig('length'); + $operator = $this->getConfig('operator'); + + // default error msg + $errorMsg = $this->getErrorMsg(); + if (empty($errorMsg)) { + + $this->setErrorMessage(sprintf("Must be %s %d character in length.", $operator, $length)); + } + + switch ($operator) { + + case '<': + if (strlen($value) >= $length) { + $this->hasError(); + } + break; + + case '>': + if (strlen($value) <= $length) { + $this->hasError(); + } + break; + + case '<=': + if (strlen($value) > $length) { + $this->hasError(); + } + break; + + case '>=': + if (strlen($value) < $length) { + $this->hasError(); + } + break; + + } + + return; + + } + + } + + +?>