| [ Index ] |
PHP Cross Reference of Limb3 |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 * Limb PHP Framework 4 * 5 * @link http://limb-project.com 6 * @copyright Copyright © 2004-2007 BIT(http://bit-creative.com) 7 * @license LGPL http://www.gnu.org/copyleft/lesser.html 8 */ 9 lmb_require('limb/validation/src/rule/lmbSingleFieldRule.class.php'); 10 lmb_require('limb/i18n/utf8.inc.php'); 11 12 /** 13 * class lmbI18NSizeRangeRule. 14 * 15 * @package validation 16 * @version $Id$ 17 */ 18 class lmbI18NSizeRangeRule extends lmbSingleFieldRule 19 { 20 /** 21 * @var integer min field value length in glyphs 22 */ 23 protected $min_length; 24 /** 25 * @var integer max field value length in glyphs 26 */ 27 protected $max_length; 28 29 function __construct($field_name, $min_length, $max_length = NULL, $custom_error = '') 30 { 31 if(is_null($max_length)) 32 { 33 $this->min_length = null; 34 $this->max_length = $min_length; 35 } 36 else 37 { 38 $this->min_length = $min_length; 39 $this->max_length = $max_length; 40 } 41 42 parent :: __construct($field_name, $custom_error); 43 } 44 45 function check($value) 46 { 47 if(!is_null($this->min_length) && (lmb_strlen($value) < $this->min_length)) 48 { 49 $this->error(lmb_i18n('{Field} must be greater than {min} and less than {max} characters.', 'validation'), 50 array('min' => $this->min_length, 'max' => $this->max_length)); 51 } 52 53 if(lmb_strlen($value) > $this->max_length) 54 { 55 $this->error(lmb_i18n('{Field} must be less than {max} and greater than {min} characters.', 'validation'), 56 array('min' => $this->min_length, 'max' => $this->max_length)); 57 } 58 } 59 } 60 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Fri Aug 29 04:49:26 2008 | Cross-referenced by PHPXref 0.7 |