Changeset 5984


Ignore:
Timestamp:
02/01/12 18:47:37 (4 months ago)
Author:
vain
Message:
  • added formvalidators for ip, email, url
  • modified range to not use the min/maxlength validators internally, but filter_validate_int
Location:
trunk/core/viewhelper/form/validators
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/viewhelper/form/validators/range.php

    r5973 r5984  
    4040{ 
    4141    /** 
    42      * @var Clansuite_Formelement_Validator_Minlength 
     42     * @var filter var options 
    4343     */ 
    44     private $validator_minlength; 
    45  
    46     /** 
    47      * @var Clansuite_Formelement_Validator_Maxlength 
    48      */ 
    49     private $validator_maxlength; 
    50  
    51     public function __construct() 
    52     { 
    53         $this->validator_minlength = Clansuite_Formelement_Validator_Minlength(); 
    54         $this->validator_maxlength = Clansuite_Formelement_Validator_Maxlength(); 
    55     } 
     44    private $options = array(); 
    5645 
    5746    /** 
     
    6352    public function setRange($minimum_length, $maximum_length) 
    6453    { 
    65         $this->validator_minlength->setMinlength($minimum_length); 
    66         $this->validator_maxlength->setMaxlength($maximum_length); 
     54        $this->options['options']['min_range'] = $minimum_length; 
     55        $this->options['options']['max_range'] = $maximum_length; 
    6756    } 
    6857 
    6958    public function getErrorMessage() 
    7059    { 
    71         $min = $this->validator_minlength->getMinlength(); 
    72         $max = $this->validator_maxlength->setMaxlength(); 
     60        $min = $this->options['options']['min_range'] 
     61        $max = $this->options['options']['max_range'] 
    7362 
    7463        return _('The value is outside the range of ' . $min .' <> '. $max .' chars.'); 
     
    7766    protected function processValidationLogic($value) 
    7867    { 
    79         if($this->validator_maxlength->validate($value) === true and $this->validator_minlength->validate($value) === true) 
     68        if(filter_var($value, FILTER_VALIDATE_INT, $this->options) !== FALSE)) 
    8069        { 
    8170            return true; 
Note: See TracChangeset for help on using the changeset viewer.