Changeset 5985


Ignore:
Timestamp:
02/01/12 18:58:34 (4 months ago)
Author:
vain
Message:
  • added getter and setter for $options on formelementvalidator base class
  • replaced $options array with $this->getOptions() accordingly in url and ip validator
  • added comments to ip validators
  • tixed fypos in validator range.php
Location:
trunk/core/viewhelper/form
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/core/viewhelper/form/formelementvalidator.php

    r5925 r5985  
    4747 
    4848    /** 
     49     * General prupose options array. 
     50     * For instance, this options array is passed as third parameter to 
     51     * filter_var($value, FILTER_CONSTANT, $options). 
     52     * 
     53     * @var array 
     54     */ 
     55    public $options = array(); 
     56 
     57    /** 
     58     * Getter for Options. 
     59     * 
     60     * @return array 
     61     */ 
     62    public function getOptions() 
     63    { 
     64        return $this->options; 
     65    } 
     66 
     67    /** 
     68     * Setter for Options. 
     69     * 
     70     * @param array $options 
     71     */ 
     72    public function setOptions(array $options) 
     73    { 
     74        $this->options = $options; 
     75    } 
     76 
     77    /** 
    4978     * Setter for the error state of the validator. 
    5079     * 
     
    86115 
    87116    /** 
    88      * Accepts an options array and assigns object property names (by key) and values (by value) accordingly. 
     117     * Accepts an array and assigns object property names (by key) and values (by value) accordingly. 
    89118     * The objects needs a setter method for the value. 
    90119     * 
  • trunk/core/viewhelper/form/validators/ip.php

    r5984 r5985  
    3737} 
    3838 
     39/** 
     40 * Validator for an IP address. 
     41 * The validator accepts IPv4 and IPv6 addresses. 
     42 * If you want only one version, use the flags FILTER_FLAG_IPV4 
     43 * or FILTER_FLAG_IPV6 via setOptions(). 
     44 * 
     45 * @see http://www.php.net/manual/en/filter.filters.validate.php 
     46 */ 
    3947class Clansuite_Formelement_Validator_Ip extends Clansuite_Formelement_Validator 
    4048{ 
     
    4654    protected function processValidationLogic($value) 
    4755    { 
    48         $options = array(); 
    49  
    50         if(true === (bool) filter_var( $value, FILTER_VALIDATE_IP, $options )) 
     56        if(true === (bool) filter_var( $value, FILTER_VALIDATE_IP, $this->getOptions() )) 
    5157        { 
    5258            return true; 
  • trunk/core/viewhelper/form/validators/maxlength.php

    r5973 r5985  
    3737} 
    3838 
     39/** 
     40 * Validates the lenght of a string with maxlength given. 
     41 */ 
    3942class Clansuite_Formelement_Validator_Maxlength extends Clansuite_Formelement_Validator 
    4043{ 
  • trunk/core/viewhelper/form/validators/minlength.php

    r5973 r5985  
    3737} 
    3838 
     39/** 
     40 * Validates the lenght of a string with maxlength given. 
     41 */ 
    3942class Clansuite_Formelement_Validator_Minlength extends Clansuite_Formelement_Validator 
    4043{ 
  • trunk/core/viewhelper/form/validators/range.php

    r5984 r5985  
    5858    public function getErrorMessage() 
    5959    { 
    60         $min = $this->options['options']['min_range'] 
    61         $max = $this->options['options']['max_range'] 
     60        $min = $this->options['options']['min_range']; 
     61        $max = $this->options['options']['max_range']; 
    6262 
    6363        return _('The value is outside the range of ' . $min .' <> '. $max .' chars.'); 
     
    6666    protected function processValidationLogic($value) 
    6767    { 
    68         if(filter_var($value, FILTER_VALIDATE_INT, $this->options) !== FALSE)) 
     68        if(filter_var($value, FILTER_VALIDATE_INT, $this->options) !== FALSE) 
    6969        { 
    7070            return true; 
  • trunk/core/viewhelper/form/validators/url.php

    r5984 r5985  
    4646    protected function processValidationLogic($value) 
    4747    { 
    48         $options = array(); 
    49          
    50         if(true === (bool) filter_var( $value, FILTER_VALIDATE_URL, $options )) 
     48        if(true === (bool) filter_var( $value, FILTER_VALIDATE_URL, $this->getOptions() )) 
    5149        { 
    5250            return true; 
Note: See TracChangeset for help on using the changeset viewer.