Przeglądaj źródła

[ZF-7513] Zend_Validate:

- fixed returned message templates

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@17469 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 lat temu
rodzic
commit
e9ccd6d6bd

+ 2 - 2
library/Zend/Validate/Abstract.php

@@ -246,11 +246,11 @@ abstract class Zend_Validate_Abstract implements Zend_Validate_Interface
     }
 
     /**
-     * @param  string $messageKey OPTIONAL
+     * @param  string $messageKey
      * @param  string $value      OPTIONAL
      * @return void
      */
-    protected function _error($messageKey = null, $value = null)
+    protected function _error($messageKey, $value = null)
     {
         if ($messageKey === null) {
             $keys = array_keys($this->_messageTemplates);

+ 3 - 3
library/Zend/Validate/Float.php

@@ -104,7 +104,7 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
             $valueFiltered = str_replace($locale['decimal_point'], '.', $valueFiltered);
 
             if (strval(floatval($valueFiltered)) != $valueFiltered) {
-                $this->_error();
+                $this->_error(self::NOT_FLOAT);
                 return false;
             }
 
@@ -112,11 +112,11 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
             try {
                 if (!Zend_Locale_Format::isFloat($value, array('locale' => 'en')) &&
                     !Zend_Locale_Format::isFloat($value, array('locale' => $this->_locale))) {
-                    $this->_error();
+                    $this->_error(self::NOT_FLOAT);
                     return false;
                 }
             } catch (Zend_Locale_Exception $e) {
-                $this->_error();
+                $this->_error(self::NOT_FLOAT);
                 return false;
             }
         }

+ 1 - 1
library/Zend/Validate/GreaterThan.php

@@ -105,7 +105,7 @@ class Zend_Validate_GreaterThan extends Zend_Validate_Abstract
         $this->_setValue($value);
 
         if ($this->_min >= $value) {
-            $this->_error();
+            $this->_error(self::NOT_GREATER);
             return false;
         }
         return true;

+ 1 - 1
library/Zend/Validate/Hex.php

@@ -65,7 +65,7 @@ class Zend_Validate_Hex extends Zend_Validate_Abstract
 
         $this->_setValue($value);
         if (!ctype_xdigit((string) $value)) {
-            $this->_error();
+            $this->_error(self::NOT_HEX);
             return false;
         }
 

+ 1 - 1
library/Zend/Validate/InArray.php

@@ -129,7 +129,7 @@ class Zend_Validate_InArray extends Zend_Validate_Abstract
     {
         $this->_setValue($value);
         if (!in_array($value, $this->_haystack, $this->_strict)) {
-            $this->_error();
+            $this->_error(self::NOT_IN_ARRAY);
             return false;
         }
         return true;

+ 3 - 3
library/Zend/Validate/Int.php

@@ -104,7 +104,7 @@ class Zend_Validate_Int extends Zend_Validate_Abstract
             $valueFiltered = str_replace($locale['thousands_sep'], '', $valueFiltered);
 
             if (strval(intval($valueFiltered)) != $valueFiltered) {
-                $this->_error();
+                $this->_error(self::NOT_INT);
                 return false;
             }
 
@@ -112,11 +112,11 @@ class Zend_Validate_Int extends Zend_Validate_Abstract
             try {
                 if (!Zend_Locale_Format::isInteger($value, array('locale' => 'en')) &&
                     !Zend_Locale_Format::isInteger($value, array('locale' => $this->_locale))) {
-                    $this->_error();
+                    $this->_error(self::NOT_INT);
                     return false;
                 }
             } catch (Zend_Locale_Exception $e) {
-                $this->_error();
+                $this->_error(self::NOT_INT);
                 return false;
             }
         }

+ 2 - 2
library/Zend/Validate/Ip.php

@@ -62,10 +62,10 @@ class Zend_Validate_Ip extends Zend_Validate_Abstract
 
         if ((ip2long($value) === false) || (long2ip(ip2long($value)) !== $value)) {
             if (!function_exists('inet_pton')) {
-                $this->_error();
+                $this->_error(self::NOT_IP_ADDRESS);
                 return false;
             } else if ((@inet_pton($value) === false) ||(inet_ntop(@inet_pton($value)) !== $value)) {
-                $this->_error();
+                $this->_error(self::NOT_IP_ADDRESS);
                 return false;
             }
         }

+ 1 - 1
library/Zend/Validate/LessThan.php

@@ -104,7 +104,7 @@ class Zend_Validate_LessThan extends Zend_Validate_Abstract
     {
         $this->_setValue($value);
         if ($this->_max <= $value) {
-            $this->_error();
+            $this->_error(self::NOT_LESS);
             return false;
         }
         return true;

+ 1 - 1
library/Zend/Validate/Regex.php

@@ -117,7 +117,7 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
             throw new Zend_Validate_Exception("Internal error matching pattern '$this->_pattern' against value '$value'");
         }
         if (!$status) {
-            $this->_error();
+            $this->_error(self::NOT_MATCH);
             return false;
         }
         return true;

+ 1 - 1
library/Zend/Validate/Sitemap/Changefreq.php

@@ -80,7 +80,7 @@ class Zend_Validate_Sitemap_Changefreq extends Zend_Validate_Abstract
         }
 
         if (!in_array($value, $this->_changeFreqs, true)) {
-            $this->_error();
+            $this->_error(self::NOT_VALID);
             return false;
         }