From 7f7aa89874e53df2d8348aa7a115b57fbeb2591b Mon Sep 17 00:00:00 2001 From: zYne Date: Tue, 22 Aug 2006 08:47:27 +0000 Subject: [PATCH] Ip and blank validators updated --- Doctrine/Validator/Ip.php | 10 +--------- Doctrine/Validator/Notblank.php | 9 +-------- manual/documentation.php | 2 +- 3 files changed, 3 insertions(+), 18 deletions(-) diff --git a/Doctrine/Validator/Ip.php b/Doctrine/Validator/Ip.php index 2f7bc740c..e7357e033 100644 --- a/Doctrine/Validator/Ip.php +++ b/Doctrine/Validator/Ip.php @@ -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)); } } ?> diff --git a/Doctrine/Validator/Notblank.php b/Doctrine/Validator/Notblank.php index fd83d8907..412556c34 100644 --- a/Doctrine/Validator/Notblank.php +++ b/Doctrine/Validator/Notblank.php @@ -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) != ""); } } ?> diff --git a/manual/documentation.php b/manual/documentation.php index ab5f8b6e0..f6bdc3caf 100644 --- a/manual/documentation.php +++ b/manual/documentation.php @@ -177,7 +177,7 @@ $menu = array("Getting started" => "Overview", "List of exceptions" ) - ), + ), "Mapping object relations" => array( "Introduction",