Adding changes that where made to validation class that I forgot to commit

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4198 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2006-12-25 10:22:48 +00:00
parent 14438cb151
commit d773f0f8d3

View file

@ -337,6 +337,7 @@ class Validation extends Object {
* @access public * @access public
*/ */
function custom($check, $regex = null) { function custom($check, $regex = null) {
$this->__reset();
$this->check = $check; $this->check = $check;
$this->regex = $regex; $this->regex = $regex;
if (is_array($check)) { if (is_array($check)) {
@ -403,7 +404,7 @@ class Validation extends Object {
} }
/** /**
* Checks that a value is a valid decimal. If $places is null, the $check is allow to be a scientific float * Checks that a value is a valid decimal. If $places is null, the $check is allowed to be a scientific float
* If no decimal point is found a false will be returned. Both the sign and exponent are optional. * If no decimal point is found a false will be returned. Both the sign and exponent are optional.
* *
* @param integer $check The value the test for decimal * @param integer $check The value the test for decimal
@ -413,6 +414,7 @@ class Validation extends Object {
* @access public * @access public
*/ */
function decimal($check, $places = null, $regex = null) { function decimal($check, $places = null, $regex = null) {
$this->__reset();
$this->regex = $regex; $this->regex = $regex;
$this->check = $check; $this->check = $check;
@ -421,39 +423,50 @@ class Validation extends Object {
} }
if(is_null($places)) { if(is_null($places)) {
$this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/s'; $this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]+(?:[eE][-+]?[0-9]+)?$/';
return $this->_check(); return $this->_check();
} }
$this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]{'.$places.'}$/s'; $this->regex = '/^[-+]?[0-9]*\\.{1}[0-9]{'.$places.'}$/';
return $this->_check(); return $this->_check();
} }
function email($check, $regex= null, $deep = false) { /**
* Enter description here...
*
* @param string $check
* @param boolean $deep
* @param string $regex
* @return boolean
* @access public
*/
function email($check, $deep = false, $regex= null) {
$this->__reset();
$this->check = $check;
$this->regex = $regex;
$this->deep = $deep;
if (is_array($check)) { if (is_array($check)) {
$this->_extract($check); $this->_extract($check);
} else {
$this->check = $check;
$this->regex = $regex;
$this->deep = $deep;
} }
if(is_null($this->regex)) { if(is_null($this->regex)) {
$this->regex = '/\\A(?:^([a-z0-9][a-z0-9_\\-\\.\\+]*)@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.(com|org|net|biz|info|name|net|pro|aero|coop|museum|[a-z]{2,4}))$)\\z/i'; $this->regex = '/\\A(?:^([a-z0-9][a-z0-9_\\-\\.\\+]*)@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.(com|org|net|biz|info|name|net|pro|aero|coop|museum|[a-z]{2,4}))$)\\z/i';
} }
$return = $this->_check();
if($this->_check() && $this->deep) { if($this->deep === false || $this->deep === null) {
if (preg_match('/@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.([a-z]*))/', $check, $regs)) { return $return;
$host = gethostbynamel($regs[1]); }
if (is_array($host)) {
$this->error[] = false; if ($return === true && preg_match('/@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.([a-z]*))/', $this->check, $regs)) {
return true; $host = gethostbynamel($regs[1]);
} else { if (is_array($host)) {
$this->error[] = true; return true;
return false;
}
} }
} }
return false;
} }
function equalTo($check, $comparedTo) { function equalTo($check, $comparedTo) {