mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-07 12:36:25 +00:00
Implementing Validation::ip()
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4265 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
50149aeeed
commit
98f32860a9
1 changed files with 22 additions and 1 deletions
|
@ -477,8 +477,25 @@ class Validation extends Object {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validation of an IPv4 address.
|
||||||
|
*
|
||||||
|
* @param string $check The string to test.
|
||||||
|
* @return boolean
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
function ip($check) {
|
function ip($check) {
|
||||||
|
$bytes = explode('.', $check);
|
||||||
|
if (count($bytes) == 4) {
|
||||||
|
$returnValue = true;
|
||||||
|
foreach ($bytes as $byte) {
|
||||||
|
if (!(is_numeric($byte) && $byte >= 0 && $byte <= 255)) {
|
||||||
|
$returnValue = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $returnValue;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -486,6 +503,8 @@ class Validation extends Object {
|
||||||
*
|
*
|
||||||
* @param string $check The string to test
|
* @param string $check The string to test
|
||||||
* @param int $min The minimal string length
|
* @param int $min The minimal string length
|
||||||
|
* @return boolean
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
function minLength($check, $min) {
|
function minLength($check, $min) {
|
||||||
$length = strlen($check);
|
$length = strlen($check);
|
||||||
|
@ -497,6 +516,8 @@ class Validation extends Object {
|
||||||
*
|
*
|
||||||
* @param string $check The string to test
|
* @param string $check The string to test
|
||||||
* @param int $max The maximal string length
|
* @param int $max The maximal string length
|
||||||
|
* @return boolean
|
||||||
|
* @access public
|
||||||
*/
|
*/
|
||||||
function maxLength($check, $max) {
|
function maxLength($check, $max) {
|
||||||
$length = strlen($check);
|
$length = strlen($check);
|
||||||
|
|
Loading…
Add table
Reference in a new issue