Changeset 5985
- Timestamp:
- 02/01/12 18:58:34 (4 months ago)
- Location:
- trunk/core/viewhelper/form
- Files:
-
- 6 edited
-
formelementvalidator.php (modified) (2 diffs)
-
validators/ip.php (modified) (2 diffs)
-
validators/maxlength.php (modified) (1 diff)
-
validators/minlength.php (modified) (1 diff)
-
validators/range.php (modified) (2 diffs)
-
validators/url.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/core/viewhelper/form/formelementvalidator.php
r5925 r5985 47 47 48 48 /** 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 /** 49 78 * Setter for the error state of the validator. 50 79 * … … 86 115 87 116 /** 88 * Accepts an optionsarray 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. 89 118 * The objects needs a setter method for the value. 90 119 * -
trunk/core/viewhelper/form/validators/ip.php
r5984 r5985 37 37 } 38 38 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 */ 39 47 class Clansuite_Formelement_Validator_Ip extends Clansuite_Formelement_Validator 40 48 { … … 46 54 protected function processValidationLogic($value) 47 55 { 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() )) 51 57 { 52 58 return true; -
trunk/core/viewhelper/form/validators/maxlength.php
r5973 r5985 37 37 } 38 38 39 /** 40 * Validates the lenght of a string with maxlength given. 41 */ 39 42 class Clansuite_Formelement_Validator_Maxlength extends Clansuite_Formelement_Validator 40 43 { -
trunk/core/viewhelper/form/validators/minlength.php
r5973 r5985 37 37 } 38 38 39 /** 40 * Validates the lenght of a string with maxlength given. 41 */ 39 42 class Clansuite_Formelement_Validator_Minlength extends Clansuite_Formelement_Validator 40 43 { -
trunk/core/viewhelper/form/validators/range.php
r5984 r5985 58 58 public function getErrorMessage() 59 59 { 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']; 62 62 63 63 return _('The value is outside the range of ' . $min .' <> '. $max .' chars.'); … … 66 66 protected function processValidationLogic($value) 67 67 { 68 if(filter_var($value, FILTER_VALIDATE_INT, $this->options) !== FALSE) )68 if(filter_var($value, FILTER_VALIDATE_INT, $this->options) !== FALSE) 69 69 { 70 70 return true; -
trunk/core/viewhelper/form/validators/url.php
r5984 r5985 46 46 protected function processValidationLogic($value) 47 47 { 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() )) 51 49 { 52 50 return true;
Note: See TracChangeset
for help on using the changeset viewer.
