Ip and blank validators updated
This commit is contained in:
parent
f554dac568
commit
7f7aa89874
@ -8,15 +8,7 @@ class Doctrine_Validator_Ip {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function validate(Doctrine_Record $record, $key, $value, $args) {
|
public function validate(Doctrine_Record $record, $key, $value, $args) {
|
||||||
$e = explode(".",$request);
|
return (bool)ip2long(str_replace("\0", '', $value));
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -8,14 +8,7 @@ class Doctrine_Validator_Notblank {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function validate(Doctrine_Record $record, $key, $value, $args) {
|
public function validate(Doctrine_Record $record, $key, $value, $args) {
|
||||||
$string = str_replace("\n","",$value);
|
return (trim($var) != "");
|
||||||
$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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user