Example #1
0
	public function valueForSql()
	{
		if(!is_null($this->value) && $this->value==='' && !$this->allowNull)
			$this->value = '';	//In case of string we do not throw an exception, we can use '' as value
		else
			return parent::valueForSql();
	}
Example #2
0
	public function valueForSql()
	{
		$value = parent::valueForSql();
		if(is_string($value) && !isset($this->options['enumValues'][$value]))
			$this->throwErrorValue();
		return $value;
	}
Example #3
0
	public function valueForSql()
	{	//A password theoretically may be an empty string, so we need to hash it
		if(!is_null($this->value) && $this->value==='' && !$this->allowNull)
			$this->value = '';
		else
			return parent::valueForSql();
	}
Example #4
0
	public function validateValue($value)
	{
		if(!parent::validateValue($value))
			return false;
		list($hour, $minute, $second) = explode(':', $value);
		list($hour, $minute, $second) = array(intval($hour), intval($minute), intval($second));
		$pattern = '/(\-?\d{1,})[\-\:\.\s](\d{1,2})[\-\:\.\s](\d{1,2})/';
		if(!empty($this->options['min']))
		{
			if(!preg_match($pattern, $this->options['min'], $matches))
				throw new AAException;
			if($hour < intval($matches[1])
					|| ($hour == intval($matches[1]) && ($minute < intval($matches[2]) || ($minute == intval($matches[2]) && $second < intval($matches[3])))))
				return false;
		}
		if(!empty($this->options['max']))
		{
			if(!preg_match($pattern, $this->options['max'], $matches))
				throw new AAException;
			if($hour > intval($matches[1])
					|| ($hour == intval($matches[1]) && ($minute > intval($matches[2]) || ($minute == intval($matches[2]) && $second > intval($matches[3])))))
				return false;
		}
		elseif($minute > 59 || $second > 59)
			return false;

		return true;
	}
Example #5
0
	public function validateValue($value)
	{
		if(!parent::validateValue($value))
			return false;
		if(!empty($this->options['min']))
		{	
			try
			{
				$dMin = new DateTime($this->options['min']);
			}
			catch (AAException $e)
			{
				throw new AAException;
			}
			if($value < $dMin)
				return false;
		}
		if(!empty($this->options['max']))
		{
			try
			{
				$dMax = new DateTime($this->options['max']);
			}
			catch (AAException $e)
			{
				throw new AAException;
			}
			if($value > $dMax)
				return false;
		}
		return true;
	}
Example #6
0
	public function validateValue($value)
	{
		if(!parent::validateValue($value))
			return false;
		if(isset($this->options['min']))
		{
			if(!is_numeric($this->options['min']))
				throw new AAException;
			if($value < $this->options['min'])
				return false;
		}
		if(isset($this->options['max']))
		{
			if(!is_numeric($this->options['max']))
				throw new AAException;
			if($value > $this->options['max'])
				return false;
		}
		return true;
	}