mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding changes to Validation::alphaNumeric().
Added doc comment to Validation::alphaNumeric() and Validation::between() git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3835 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
20da5e67a7
commit
d2ffbe2016
1 changed files with 33 additions and 0 deletions
|
@ -80,10 +80,43 @@ class Validation extends Object {
|
|||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a string contains only integer or letters
|
||||
*
|
||||
* Returns true if string contains only integer or letters
|
||||
*
|
||||
* $check can be passed as an array:
|
||||
* array('check' => 'valueToCheck');
|
||||
*
|
||||
* @param mixed $check
|
||||
* @return boolean
|
||||
*/
|
||||
function alphaNumeric($check) {
|
||||
if (is_array($check)) {
|
||||
$this->_extract($check);
|
||||
} else {
|
||||
$this->check = $check;
|
||||
}
|
||||
|
||||
$this->regex = '/[^\\dA-Z]/i';
|
||||
if($this->_check() === true){
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks that a string is within s specified range.
|
||||
|
||||
* Spaces are included in the character count
|
||||
* Returns true is string matches value min, max, or between min and max,
|
||||
*
|
||||
* @param string $check
|
||||
* @param int $min
|
||||
* @param int $max
|
||||
* @return boolean
|
||||
*/
|
||||
function between($check, $min, $max) {
|
||||
$length = strlen($check);
|
||||
if ($length >= $min && $length <= $max) {
|
||||
|
|
Loading…
Reference in a new issue