Ip and blank validators updated
This commit is contained in:
parent
f554dac568
commit
7f7aa89874
@ -8,15 +8,7 @@ class Doctrine_Validator_Ip {
|
||||
* @return boolean
|
||||
*/
|
||||
public function validate(Doctrine_Record $record, $key, $value, $args) {
|
||||
$e = explode(".",$request);
|
||||
if(count($e) != 4) return false;
|
||||
|
||||
foreach($e as $k=>$v):
|
||||
if(! is_numeric($v)) return false;
|
||||
$v = (int) $v;
|
||||
if($v < 0 || $v > 255) return false;
|
||||
endforeach;
|
||||
return true;
|
||||
return (bool)ip2long(str_replace("\0", '', $value));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -8,14 +8,7 @@ class Doctrine_Validator_Notblank {
|
||||
* @return boolean
|
||||
*/
|
||||
public function validate(Doctrine_Record $record, $key, $value, $args) {
|
||||
$string = str_replace("\n","",$value);
|
||||
$string = str_replace("\r","",$string);
|
||||
$string = str_replace("\t","",$string);
|
||||
$string = str_replace("\s","",$string);
|
||||
$string = str_replace(" ","",$string);
|
||||
if($string == "") return false;
|
||||
|
||||
return true;
|
||||
return (trim($var) != "");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -177,7 +177,7 @@ $menu = array("Getting started" =>
|
||||
"Overview",
|
||||
"List of exceptions"
|
||||
)
|
||||
),
|
||||
),
|
||||
"Mapping object relations" =>
|
||||
array(
|
||||
"Introduction",
|
||||
|
Loading…
x
Reference in New Issue
Block a user