Esempio n. 1
0
 /**
 	Initialises a new number validator.
 
 	@param	$aArgs						The configuration arguments of the validator.
 	@throw	DomainException				The `format` argument is invalid.
 	@throw	DomainException				The `max` argument is invalid.
 	@throw	DomainException				The `min` argument is invalid.
 	@throw	InvalidArgumentException	The `min` and `max` arguments do not form a valid number range.
 */
 public function __construct(array $aArgs = array())
 {
     !isset($aArgs['format']) or $aArgs['format'] == 'int' or $aArgs['format'] == 'float' or burn('InvalidArgumentException', _WT('The "format" argument must be of type int or float.'));
     !isset($aArgs['min']) or $this->isValidInput($aArgs['min']) or burn('DomainException', sprintf(_WT('The "%s" argument is invalid.'), 'min'));
     !isset($aArgs['max']) or $this->isValidInput($aArgs['max']) or burn('DomainException', sprintf(_WT('The "%s" argument is invalid.'), 'max'));
     if (isset($aArgs['min'], $aArgs['max'])) {
         (double) $aArgs['min'] < $aArgs['max'] or burn('InvalidArgumentException', _WT('The "min" and "max" arguments do not form a valid range.'));
     }
     parent::__construct($aArgs);
 }
Esempio n. 2
0
 /**
 	Initialises a string validator.
 
 	@param	$aArgs						The configuration arguments of the validator.
 	@throw	DomainException				The `len` argument is invalid.
 	@throw	DomainException				The `min` argument is invalid.
 	@throw	DomainException				The `max` argument is invalid.
 	@throw	InvalidArgumentException	The `min` and `max` arguments do not form a valid length range.
 	@throw	InvalidArgumentException	The `len` and one of the `min` or `max` arguments are both specified.
 */
 public function __construct(array $aArgs = array())
 {
     !isset($aArgs['len']) or filter_var($aArgs['len'], FILTER_VALIDATE_INT) !== false and $aArgs['len'] >= 0 or burn('DomainException', sprintf(_WT('The "%s" argument is invalid.'), 'len'));
     !isset($aArgs['min']) or filter_var($aArgs['min'], FILTER_VALIDATE_INT) !== false and $aArgs['min'] >= 0 or burn('DomainException', sprintf(_WT('The "%s" argument is invalid.'), 'min'));
     !isset($aArgs['max']) or filter_var($aArgs['max'], FILTER_VALIDATE_INT) !== false and $aArgs['max'] >= 0 or burn('DomainException', sprintf(_WT('The "%s" argument is invalid.'), 'max'));
     if (isset($aArgs['min'], $aArgs['max'])) {
         (int) $aArgs['min'] < $aArgs['max'] or burn('InvalidArgumentException', _WT('The "min" and "max" arguments do not form a valid range.'));
     }
     !isset($aArgs['len']) or !isset($aArgs['min']) and !isset($aArgs['max']) or burn('InvalidArgumentException', _WT('The "len" argument should not be specified when "min" or "max" is defined.'));
     parent::__construct($aArgs);
 }
Esempio n. 3
0
 /**
 	Initialises a new date validator.
 
 	@param	$aArgs						The configuration arguments of the validator.
 	@throw	DomainException				The `max` argument is invalid.
 	@throw	DomainException				The `min` argument is invalid.
 	@throw	InvalidArgumentException	The `min` and `max` arguments do not form a valid date range.
 */
 public function __construct(array $aArgs = array())
 {
     !isset($aArgs['min']) or is_string($aArgs['min']) and ($aArgs['min'] == 'current' or $this->isValidInput($aArgs['min'])) or burn('DomainException', sprintf(_WT('The "%s" argument is invalid.'), 'min'));
     !isset($aArgs['max']) or is_string($aArgs['max']) and ($aArgs['max'] == 'current' or $this->isValidInput($aArgs['max'])) or burn('DomainException', sprintf(_WT('The "%s" argument is invalid.'), 'max'));
     if (isset($aArgs['min'], $aArgs['max'])) {
         if ($aArgs['min'] == 'current' or $aArgs['max'] == 'current') {
             $sToday = date('Y-m-d');
         }
         $sMin = $aArgs['min'] == 'current' ? $sToday : $aArgs['min'];
         $sMax = $aArgs['max'] == 'current' ? $sToday : $aArgs['max'];
         $sMin < $sMax or burn('InvalidArgumentException', _WT('The "min" and "max" arguments do not form a valid range.'));
     }
     parent::__construct($aArgs);
 }