Переглянути джерело

[ZF-1598 (incomplete), ZF-6623 (incomplete), ZF-7153] Zend_Validate*:

rewrote / unified all validators
- erased depreciated method from interface (no longer needed)
- fixed several manual descriptions and examples
- added Zend_Config support for parameters to all validators
- added Array support for parameters to all validators

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@18028 44c647ce-9c0f-0410-b52a-842ac1e357ba
thomas 16 роки тому
батько
коміт
d55ac30d12
49 змінених файлів з 733 додано та 280 видалено
  1. 38 12
      documentation/manual/en/module_specs/Zend_Validate-Db.xml
  2. 141 7
      documentation/manual/en/module_specs/Zend_Validate-EmailAddress.xml
  3. 14 34
      documentation/manual/en/module_specs/Zend_Validate-Hostname.xml
  4. 2 2
      documentation/manual/en/module_specs/Zend_Validate-ValidatorChains.xml
  5. 37 31
      documentation/manual/en/module_specs/Zend_Validate-WritingValidators.xml
  6. 8 8
      documentation/manual/en/module_specs/Zend_Validate.xml
  7. 14 1
      library/Zend/Validate.php
  8. 11 1
      library/Zend/Validate/Alnum.php
  9. 11 1
      library/Zend/Validate/Alpha.php
  10. 17 7
      library/Zend/Validate/Barcode.php
  11. 0 3
      library/Zend/Validate/Barcode/Ean13.php
  12. 0 3
      library/Zend/Validate/Barcode/UpcA.php
  13. 40 10
      library/Zend/Validate/Between.php
  14. 0 4
      library/Zend/Validate/Ccnum.php
  15. 28 8
      library/Zend/Validate/Date.php
  16. 57 16
      library/Zend/Validate/Db/Abstract.php
  17. 0 1
      library/Zend/Validate/Db/NoRecordExists.php
  18. 0 2
      library/Zend/Validate/Db/RecordExists.php
  19. 0 4
      library/Zend/Validate/Digits.php
  20. 0 3
      library/Zend/Validate/Exception.php
  21. 3 3
      library/Zend/Validate/File/Count.php
  22. 1 1
      library/Zend/Validate/File/Crc32.php
  23. 1 1
      library/Zend/Validate/File/Exists.php
  24. 3 3
      library/Zend/Validate/File/Extension.php
  25. 12 12
      library/Zend/Validate/File/FilesSize.php
  26. 2 1
      library/Zend/Validate/File/Hash.php
  27. 2 6
      library/Zend/Validate/File/ImageSize.php
  28. 4 2
      library/Zend/Validate/File/IsCompressed.php
  29. 4 2
      library/Zend/Validate/File/IsImage.php
  30. 2 1
      library/Zend/Validate/File/Size.php
  31. 5 1
      library/Zend/Validate/File/Upload.php
  32. 11 1
      library/Zend/Validate/Float.php
  33. 11 4
      library/Zend/Validate/GreaterThan.php
  34. 0 3
      library/Zend/Validate/Hex.php
  35. 11 1
      library/Zend/Validate/Iban.php
  36. 10 0
      library/Zend/Validate/Identical.php
  37. 11 1
      library/Zend/Validate/Int.php
  38. 0 15
      library/Zend/Validate/Interface.php
  39. 11 5
      library/Zend/Validate/LessThan.php
  40. 11 4
      library/Zend/Validate/Regex.php
  41. 0 1
      library/Zend/Validate/Sitemap/Lastmod.php
  42. 36 6
      library/Zend/Validate/StringLength.php
  43. 7 6
      tests/Zend/Validate/BetweenTest.php
  44. 3 0
      tests/Zend/Validate/DateTest.php
  45. 9 9
      tests/Zend/Validate/Db/NoRecordExistsTest.php
  46. 15 15
      tests/Zend/Validate/Db/RecordExistsTest.php
  47. 94 0
      tests/Zend/Validate/EmailAddressTest.php
  48. 2 1
      tests/Zend/Validate/File/FilesSizeTest.php
  49. 34 17
      tests/Zend/ValidateTest.php

+ 38 - 12
documentation/manual/en/module_specs/Zend_Validate-Db.xml

@@ -19,7 +19,13 @@
 
         <programlisting language="php"><![CDATA[
 //Check that the email address exists in the database
-$validator = new Zend_Validate_Db_RecordExists('users', 'emailaddress');
+$validator = new Zend_Validate_Db_RecordExists(
+    array(
+        'table' => 'users',
+        'field' => 'emailaddress'
+    )
+);
+
 if ($validator->isValid($emailaddress)) {
     // email address appears to be valid
 } else {
@@ -39,7 +45,12 @@ if ($validator->isValid($emailaddress)) {
 
         <programlisting language="php"><![CDATA[
 //Check that the username is not present in the database
-$validator = new Zend_Validate_Db_NoRecordExists('users', 'username');
+$validator = new Zend_Validate_Db_NoRecordExists(
+    array(
+        'table' => 'users',
+        'field' => 'username'
+    )
+);
 if ($validator->isValid($username)) {
     // username appears to be valid
 } else {
@@ -80,11 +91,13 @@ if ($validator->isValid($username)) {
 //Check no other users have the username
 $user_id   = $user->getId();
 $validator = new Zend_Validate_Db_NoRecordExists(
-    'users',
-    'username',
     array(
-        'field' => 'id',
-        'value' => $user_id
+        'table' => 'users',
+        'field' => 'username',
+        'exclude' => array(
+            'field' => 'id',
+            'value' => $user_id
+        )
     )
 );
 
@@ -115,9 +128,11 @@ if ($validator->isValid($username)) {
 $post_id   = $post->getId();
 $clause    = $db->quoteInto('post_id = ?', $category_id);
 $validator = new Zend_Validate_Db_RecordExists(
-    'posts_categories',
-    'post_id',
-    $clause
+    array(
+        'table'   => 'posts_categories',
+        'field'   => 'post_id',
+        'exclude' => $clause
+    )
 );
 
 if ($validator->isValid($username)) {
@@ -149,7 +164,13 @@ if ($validator->isValid($username)) {
         </para>
 
         <programlisting language="php"><![CDATA[
-$validator = new Zend_Validate_Db_RecordExists('users', 'id', null, $dbAdapter);
+$validator = new Zend_Validate_Db_RecordExists(
+    array(
+        'table' => 'users',
+        'field' => 'id',
+        'adapter' => $dbAdapter
+    )
+);
 ]]></programlisting>
     </sect3>
 
@@ -164,8 +185,13 @@ $validator = new Zend_Validate_Db_RecordExists('users', 'id', null, $dbAdapter);
         </para>
 
         <programlisting language="php"><![CDATA[
-$validator = new Zend_Validate_Db_RecordExists(array('table' => 'users',
-                                                     'schema' => 'my'), 'id');
+$validator = new Zend_Validate_Db_RecordExists(
+    array(
+        'table'  => 'users',
+        'schema' => 'my',
+        'field'  => 'id'
+    )
+);
 ]]></programlisting>
     </sect3>
 </sect2>

+ 141 - 7
documentation/manual/en/module_specs/Zend_Validate-EmailAddress.xml

@@ -34,6 +34,70 @@ if ($validator->isValid($email)) {
         </para>
     </sect3>
 
+    <sect3 id="zend.validate.set.email_address.options">
+        <title>Options for validating Email Addresses</title>
+
+        <para>
+            <classname>Zend_Validate_EmailAddress</classname> supports several options which can
+            eighter be set at initiation, by giving an array with the related options, or
+            afterwards, by using <methodname>setOptions()</methodname>. The following options are
+            supported:
+        </para>
+
+        <itemizedlist>
+            <listitem>
+                <para>
+                    <emphasis>allow</emphasis>: Defines which type of domain names are accepted.
+                    This option is used in conjunction with the hostname option to set the
+                    hostname validator. For more informations about possible values of this
+                    option look at <link linkend="zend.validate.set.hostname" /> and possible
+                    <constant>ALLOW</constant>* constants. This option defaults to
+                    <constant>ALLOW_DNS</constant>.
+                </para>
+            </listitem>
+
+            <listitem>
+                <para>
+                    <emphasis>hostname</emphasis>: Sets the hostname validator with which the
+                    domain part of the email address will be validated.
+                </para>
+            </listitem>
+
+            <listitem>
+                <para>
+                    <emphasis>mx</emphasis>: Defines if the MX records from the server should be
+                    detected. If this option is defined to <constant>TRUE</constant> then the MX
+                    records are used to verify if the server
+                    accepts emails. This option defaults to <constant>FALSE</constant>.
+                </para>
+            </listitem>
+
+            <listitem>
+                <para>
+                    <emphasis>deep</emphasis>: Defines if the servers MX records should be verified
+                    by a deep check. When this option is set to <constant>TRUE</constant> then
+                    additionally to MX records also the A, A6 and <constant>AAAA</constant> records
+                    are used to verify if the server accepts emails. This option defaults to
+                    <constant>FALSE</constant>.
+                </para>
+            </listitem>
+
+            <listitem>
+                <para>
+                    <emphasis>domain</emphasis>: Defines if the domain part should be checked.
+                    When this option is set to <constant>FALSE</constant>, then only the local part
+                    of the email address will be checked. In this case the hostname validator will
+                    not be called. This option defaults to <constant>TRUE</constant>.
+                </para>
+            </listitem>
+        </itemizedlist>
+
+        <programlisting language="php"><![CDATA[
+$validator = new Zend_Validate_EmailAddress();
+$validator->setOptions(array('domain' => false));
+]]></programlisting>
+    </sect3>
+
     <sect3 id="zend.validate.set.email_address.complexlocal">
         <title>Complex local parts</title>
 
@@ -50,6 +114,23 @@ if ($validator->isValid($email)) {
         </para>
     </sect3>
 
+    <sect3 id="zend.validate.set.email_address.complexlocal">
+        <title>Validating only the local part</title>
+
+        <para>
+            If you need <classname>Zend_Validate_EmailAddress</classname> to check only the local
+            part of an email address, and want to disable validation of the hostname, you can
+            set the <property>domain</property> option to <constant>FALSE</constant>. This forces
+            <classname>Zend_Validate_EmailAddress</classname> not to validate the hostname part of
+            the email address.
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$validator = new Zend_Validate_EmailAddress();
+$validator->setOptions(array('domain' => FALSE));
+]]></programlisting>
+    </sect3>
+
     <sect3 id="zend.validate.set.email_address.hostnametype">
         <title>Validating different types of hostnames</title>
 
@@ -95,16 +176,29 @@ if ($validator->isValid($email)) {
         </para>
 
         <para>
-            MX checking is not enabled by default and at this time is only supported by UNIX
-            platforms. To enable MX checking you can pass a second parameter to the
-            <classname>Zend_Validate_EmailAddress</classname> constructor.
+            MX checking is not enabled by default. To enable MX checking you can pass a second
+            parameter to the <classname>Zend_Validate_EmailAddress</classname> constructor.
         </para>
 
         <programlisting language="php"><![CDATA[
-$validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS,
-                                            true);
+$validator = new Zend_Validate_EmailAddress(
+    array(
+        'allow' => Zend_Validate_Hostname::ALLOW_DNS,
+        'mx'    => true
+    )
+);
 ]]></programlisting>
 
+        <note>
+            <title>MX Check under Windows</title>
+
+            <para>
+                Within Windows environments MX checking is only available when
+                <acronym>PHP</acronym> 5.3 or above is used. Below <acronym>PHP</acronym> 5.3 MX
+                checking will not be used even if it's activated within the options.
+            </para>
+        </note>
+
         <para>
             Alternatively you can either pass <constant>TRUE</constant> or
             <constant>FALSE</constant> to <code>$validator->setValidateMx()</code> to enable or
@@ -116,6 +210,46 @@ $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS,
             MX record on the hostname of the email address you wish to validate. Please be aware
             this will likely slow your script down.
         </para>
+
+        <para>
+            Sometimes validation for MX records returns false, even if emails are accepted. The
+            reason behind this behaviour is, that servers can accept emails even if they do not
+            provide a MX record. In this case they can provide A, A6 or <constant>AAAA</constant>
+            records. To allow <classname>Zend_Validate_EmailAddress</classname> to check also for
+            these other records you need to set deep MX validation. This can be done at initiation
+            by setting the <property>deep</property> option or by using
+            <methodname>setOptions()</methodname>.
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$validator = new Zend_Validate_EmailAddress(
+    array(
+        'allow' => Zend_Validate_Hostname::ALLOW_DNS,
+        'mx'    => true,
+        'deep'  => true
+    )
+);
+]]></programlisting>
+
+        <warning>
+            <title>Performance warning</title>
+
+            <para>
+                You should be aware that enabling MX check will slow down you script because of the
+                used network functions. Enabling deep check will slow down your script even more as
+                it searches the given server for 3 additional types.
+            </para>
+        </warning>
+
+        <note>
+            <title>Disallowed IP addresses</title>
+
+            <para>
+                You should note that MX validation is only accepted for external servers. When deep
+                MX validation is enabled, then local IP addresses like <command>192.168.*</command>
+                or <command>169.254.*</command> are not accepted.
+            </para>
+        </note>
     </sect3>
 
     <sect3 id="zend.validate.set.email_address.validateidn">
@@ -130,7 +264,7 @@ $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_DNS,
         </para>
 
         <programlisting language="php"><![CDATA[
-$validator->hostnameValidator->setValidateIdn(false);
+$validator->getHostnameValidator()->setValidateIdn(false);
 ]]></programlisting>
 
         <para>
@@ -154,7 +288,7 @@ $validator->hostnameValidator->setValidateIdn(false);
         </para>
 
         <programlisting language="php"><![CDATA[
-$validator->hostnameValidator->setValidateTld(false);
+$validator->getHostnameValidator()->setValidateTld(false);
 ]]></programlisting>
 
         <para>

+ 14 - 34
documentation/manual/en/module_specs/Zend_Validate-Hostname.xml

@@ -87,35 +87,7 @@ $validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS |
     </para>
 
     <para>
-        At present the list of supported ccTLDs include:
-
-        <itemizedlist>
-                <listitem>
-                    <para>at (Austria)</para>
-                </listitem>
-                <listitem>
-                    <para>ch (Switzerland)</para>
-                </listitem>
-                <listitem>
-                    <para>li (Liechtenstein)</para>
-                </listitem>
-                <listitem>
-                    <para>de (Germany)</para>
-                </listitem>
-                <listitem>
-                    <para>fi (Finland)</para>
-                </listitem>
-                <listitem>
-                    <para>hu (Hungary)</para>
-                </listitem>
-                <listitem>
-                    <para>no (Norway)</para>
-                </listitem>
-                <listitem>
-                    <para>se (Sweden)</para>
-                </listitem>
-        </itemizedlist>
-
+        Until now more than 50 ccTLDs support IDN domains.
     </para>
 
     <para>
@@ -131,12 +103,16 @@ $validator = new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS |
 
         <programlisting language="php"><![CDATA[
 $validator =
-    new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS, false);
+    new Zend_Validate_Hostname(
+        array(
+            'allow' => Zend_Validate_Hostname::ALLOW_DNS,
+            'idn'   => false
+        )
+    );
 ]]></programlisting>
 
         Alternatively you can either pass TRUE or FALSE to
         <code>$validator->setValidateIdn()</code> to enable or disable IDN validation.
-
         If you are trying to match an IDN hostname which isn't currently supported it is likely
         it will fail validation if it has any international characters in it. Where a ccTLD file
         doesn't exist in Zend/Validate/Hostname specifying the additional characters a normal
@@ -159,9 +135,13 @@ $validator =
 
         <programlisting language="php"><![CDATA[
 $validator =
-    new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_DNS,
-                               true,
-                               false);
+    new Zend_Validate_Hostname(
+        array(
+            'allow' => Zend_Validate_Hostname::ALLOW_DNS,
+            'idn'   => true,
+            'tld'   => false
+        )
+    );
 ]]></programlisting>
 
         Alternatively you can either pass TRUE or FALSE to

+ 2 - 2
documentation/manual/en/module_specs/Zend_Validate-ValidatorChains.xml

@@ -13,7 +13,7 @@
         <programlisting language="php"><![CDATA[
 // Create a validator chain and add validators to it
 $validatorChain = new Zend_Validate();
-$validatorChain->addValidator(new Zend_Validate_StringLength(6, 12))
+$validatorChain->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)))
                ->addValidator(new Zend_Validate_Alnum());
 
 // Validate the username
@@ -47,7 +47,7 @@ if ($validatorChain->isValid($username)) {
         fails:
 
         <programlisting language="php"><![CDATA[
-$validatorChain->addValidator(new Zend_Validate_StringLength(6, 12), true)
+$validatorChain->addValidator(new Zend_Validate_StringLength(array('min' => 6, 'max' => 12)), true)
         ->addValidator(new Zend_Validate_Alnum());
 ]]></programlisting>
 

+ 37 - 31
documentation/manual/en/module_specs/Zend_Validate-WritingValidators.xml

@@ -12,7 +12,7 @@
 
     <para>
         <classname>Zend_Validate_Interface</classname> defines three methods,
-        <methodname>isValid()</methodname>, <methodname>getMessages()</methodname>, and <methodname>getErrors()</methodname>, that may
+        <methodname>isValid()</methodname> and <methodname>getMessages()</methodname>, that may
         be implemented by user classes in order to create custom validation objects. An object that
         implements <classname>Zend_Validate_Interface</classname> interface may be added to a
         validator chain with <methodname>Zend_Validate::addValidator()</methodname>. Such objects may
@@ -56,8 +56,9 @@
             The following example demonstrates how a very simple custom validator might be written.
             In this case the validation rules are simply that the input value must be a floating
             point value.
+        </para>
 
-            <programlisting language="php"><![CDATA[
+        <programlisting language="php"><![CDATA[
 class MyValid_Float extends Zend_Validate_Abstract
 {
     const FLOAT = 'float';
@@ -80,6 +81,7 @@ class MyValid_Float extends Zend_Validate_Abstract
 }
 ]]></programlisting>
 
+        <para>
             The class defines a template for its single validation failure message, which includes
             the built-in magic parameter, <code>%value%</code>. The call to <methodname>_setValue()</methodname>
             prepares the object to insert the tested value into the failure message automatically,
@@ -100,24 +102,25 @@ class MyValid_Float extends Zend_Validate_Abstract
             required that the input value be numeric and within the range of minimum and maximum
             boundary values. An input value would fail validation for exactly one of the following
             reasons:
-
-            <itemizedlist>
-                <listitem>
-                    <para>The input value is not numeric.</para>
-                </listitem>
-                <listitem>
-                    <para>The input value is less than the minimum allowed value.</para>
-                </listitem>
-                <listitem>
-                    <para>The input value is more than the maximum allowed value.</para>
-                </listitem>
-            </itemizedlist>
         </para>
 
+        <itemizedlist>
+            <listitem>
+                <para>The input value is not numeric.</para>
+            </listitem>
+            <listitem>
+                <para>The input value is less than the minimum allowed value.</para>
+            </listitem>
+            <listitem>
+                <para>The input value is more than the maximum allowed value.</para>
+            </listitem>
+        </itemizedlist>
+
         <para>
             These validation failure reasons are then translated to definitions in the class:
+        </para>
 
-            <programlisting language="php"><![CDATA[
+        <programlisting language="php"><![CDATA[
 class MyValid_NumericBetween extends Zend_Validate_Abstract
 {
     const MSG_NUMERIC = 'msgNumeric';
@@ -162,6 +165,7 @@ class MyValid_NumericBetween extends Zend_Validate_Abstract
 }
 ]]></programlisting>
 
+        <para>
             The public properties <varname>$minimum</varname> and <varname>$maximum</varname> have been
             established to provide the minimum and maximum boundaries, respectively, for a value to
             successfully validate. The class also defines two message variables that correspond to
@@ -189,27 +193,28 @@ class MyValid_NumericBetween extends Zend_Validate_Abstract
             Consider writing a validation class for password strength enforcement - when a user is
             required to choose a password that meets certain criteria for helping secure user
             accounts. Let us assume that the password security criteria enforce that the password:
-
-            <itemizedlist>
-                <listitem>
-                    <para>is at least 8 characters in length,</para>
-                </listitem>
-                <listitem>
-                    <para>contains at least one uppercase letter,</para>
-                </listitem>
-                <listitem>
-                    <para>contains at least one lowercase letter,</para>
-                </listitem>
-                <listitem>
-                    <para>and contains at least one digit character.</para>
-                </listitem>
-            </itemizedlist>
         </para>
 
+        <itemizedlist>
+            <listitem>
+                <para>is at least 8 characters in length,</para>
+            </listitem>
+            <listitem>
+                <para>contains at least one uppercase letter,</para>
+            </listitem>
+            <listitem>
+                <para>contains at least one lowercase letter,</para>
+            </listitem>
+            <listitem>
+                <para>and contains at least one digit character.</para>
+            </listitem>
+        </itemizedlist>
+
         <para>
             The following class implements these validation criteria:
+        </para>
 
-            <programlisting language="php"><![CDATA[
+        <programlisting language="php"><![CDATA[
 class MyValid_PasswordStrength extends Zend_Validate_Abstract
 {
     const LENGTH = 'length';
@@ -255,6 +260,7 @@ class MyValid_PasswordStrength extends Zend_Validate_Abstract
 }
 ]]></programlisting>
 
+        <para>
             Note that the four criteria tests in <methodname>isValid()</methodname> do not immediately return
             <constant>FALSE</constant>. This allows the validation class to provide <emphasis>all</emphasis>
             of the reasons that the input password failed to meet the validation requirements. if,

+ 8 - 8
documentation/manual/en/module_specs/Zend_Validate.xml

@@ -146,7 +146,7 @@ if (!$validator->isValid('word')) {
             method. Its argument is an array containing key/message pairs.
 
             <programlisting language="php"><![CDATA[
-$validator = new Zend_Validate_StringLength(8, 12);
+$validator = new Zend_Validate_StringLength(array('min' => 8, 'max' => 12));
 
 $validator->setMessages( array(
     Zend_Validate_StringLength::TOO_SHORT =>
@@ -168,7 +168,7 @@ $validator->setMessages( array(
             case-by-case basis in each validation class.
 
             <programlisting language="php"><![CDATA[
-$validator = new Zend_Validate_StringLength(8, 12);
+$validator = new Zend_Validate_StringLength(array('min' => 8, 'max' => 12));
 
 if (!validator->isValid('word')) {
     echo 'Word failed: '
@@ -213,7 +213,7 @@ if (Zend_Validate::is($email, 'EmailAddress')) {
             are needed for the validator.
 
             <programlisting language="php"><![CDATA[
-if (Zend_Validate::is($value, 'Between', array(1, 12))) {
+if (Zend_Validate::is($value, 'Between', array('min' => 1, 'max' => 12))) {
     // Yes, $value is between 1 and 12
 }
 ]]></programlisting>
@@ -253,7 +253,7 @@ if (Zend_Validate::is($value, 'Between', array(1, 12))) {
             </para>
 
             <programlisting language="php"><![CDATA[
-if (Zend_Validate::is($value, 'MyValidator', array(1, 12),
+if (Zend_Validate::is($value, 'MyValidator', array('min' => 1, 'max' => 12),
                       array('FirstNamespace', 'SecondNamespace')) {
     // Yes, $value is ok
 }
@@ -268,11 +268,11 @@ if (Zend_Validate::is($value, 'MyValidator', array(1, 12),
 
             <programlisting language="php"><![CDATA[
 Zend_Validate::setDefaultNamespaces(array('FirstNamespace', 'SecondNamespace'));
-if (Zend_Validate::is($value, 'MyValidator', array(1, 12)) {
+if (Zend_Validate::is($value, 'MyValidator', array('min' => 1, 'max' => 12)) {
     // Yes, $value is ok
 }
 
-if (Zend_Validate::is($value, 'OtherValidator', array(1, 12)) {
+if (Zend_Validate::is($value, 'OtherValidator', array('min' => 1, 'max' => 12)) {
     // Yes, $value is ok
 }
 ]]></programlisting>
@@ -329,7 +329,7 @@ if (Zend_Validate::is($value, 'OtherValidator', array(1, 12)) {
         </para>
 
         <programlisting language="php"><![CDATA[
-$validator = new Zend_Validate_StringLength(8, 12);
+$validator = new Zend_Validate_StringLength(array('min' => 8, 'max' => 12));
 $translate = new Zend_Translate(
     'array',
     array(Zend_Validate_StringLength::TOO_SHORT => 'Translated \'%value%\''),
@@ -371,7 +371,7 @@ Zend_Validate::setDefaultTranslator($translate);
         </para>
 
         <programlisting language="php"><![CDATA[
-$validator = new Zend_Validate_StringLength(8, 12);
+$validator = new Zend_Validate_StringLength(array('min' => 8, 'max' => 12));
 if (!$validator->isTranslatorDisabled()) {
     $validator->setDisableTranslator();
 }

+ 14 - 1
library/Zend/Validate.php

@@ -205,7 +205,20 @@ class Zend_Validate implements Zend_Validate_Interface
                 $class = new ReflectionClass($className);
                 if ($class->implementsInterface('Zend_Validate_Interface')) {
                     if ($class->hasMethod('__construct')) {
-                        $object = $class->newInstanceArgs($args);
+                        $keys    = array_keys($args);
+                        $numeric = false;
+                        foreach($keys as $key) {
+                            if (is_numeric($key)) {
+                                $numeric = true;
+                                break;
+                            }
+                        }
+
+                        if ($numeric) {
+                            $object = $class->newInstanceArgs($args);
+                        } else {
+                            $object = $class->newInstance($args);
+                        }
                     } else {
                         $object = $class->newInstance();
                     }

+ 11 - 1
library/Zend/Validate/Alnum.php

@@ -65,11 +65,21 @@ class Zend_Validate_Alnum extends Zend_Validate_Abstract
     /**
      * Sets default option values for this instance
      *
-     * @param  boolean $allowWhiteSpace
+     * @param  boolean|Zend_Config $allowWhiteSpace
      * @return void
      */
     public function __construct($allowWhiteSpace = false)
     {
+        if ($allowWhiteSpace instanceof Zend_Config) {
+            $allowWhiteSpace = $allowWhiteSpace->toArray();
+            if (array_key_exists('allowWhiteSpace', $allowWhiteSpace)) {
+                $allowWhiteSpace = $allowWhiteSpace['allowWhiteSpace'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'allowWhiteSpace'");
+            }
+        }
+
         $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
     }
 

+ 11 - 1
library/Zend/Validate/Alpha.php

@@ -65,11 +65,21 @@ class Zend_Validate_Alpha extends Zend_Validate_Abstract
     /**
      * Sets default option values for this instance
      *
-     * @param  boolean $allowWhiteSpace
+     * @param  boolean|Zend_Config $allowWhiteSpace
      * @return void
      */
     public function __construct($allowWhiteSpace = false)
     {
+        if ($allowWhiteSpace instanceof Zend_Config) {
+            $allowWhiteSpace = $allowWhiteSpace->toArray();
+            if (array_key_exists('allowWhiteSpace', $allowWhiteSpace)) {
+                $allowWhiteSpace = $allowWhiteSpace['allowWhiteSpace'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'allowWhiteSpace'");
+            }
+        }
+
         $this->allowWhiteSpace = (boolean) $allowWhiteSpace;
     }
 

+ 17 - 7
library/Zend/Validate/Barcode.php

@@ -42,25 +42,35 @@ class Zend_Validate_Barcode extends Zend_Validate_Abstract
     /**
      * Generates the standard validator object
      *
-     * @param  string $barcodeType - Barcode validator to use
+     * @param  string|Zend_Config $barcode Barcode validator to use
      * @return void
      * @throws Zend_Validate_Exception
      */
-    public function __construct($barcodeType)
+    public function __construct($barcode)
     {
-        $this->setType($barcodeType);
+        if ($barcode instanceof Zend_Config) {
+            $barcode = $barcode->toArray();
+            if (array_key_exists('barcode', $barcode)) {
+                $barcode = $barcode['barcode'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'barcode'");
+            }
+        }
+
+        $this->setType($barcode);
     }
 
     /**
      * Sets a new barcode validator
      *
-     * @param  string $barcodeType - Barcode validator to use
+     * @param  string $barcode - Barcode validator to use
      * @return void
      * @throws Zend_Validate_Exception
      */
-    public function setType($barcodeType)
+    public function setType($barcode)
     {
-        switch (strtolower($barcodeType)) {
+        switch (strtolower($barcode)) {
             case 'upc':
             case 'upc-a':
                 require_once 'Zend/Validate/Barcode/UpcA.php';
@@ -73,7 +83,7 @@ class Zend_Validate_Barcode extends Zend_Validate_Abstract
                 break;
             default:
                 require_once 'Zend/Validate/Exception.php';
-                throw new Zend_Validate_Exception("Barcode type '$barcodeType' is not supported'");
+                throw new Zend_Validate_Exception("Barcode type '$barcode' is not supported'");
                 break;
         }
 

+ 0 - 3
library/Zend/Validate/Barcode/Ean13.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate

+ 0 - 3
library/Zend/Validate/Barcode/UpcA.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate

+ 40 - 10
library/Zend/Validate/Between.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate
@@ -91,17 +88,50 @@ class Zend_Validate_Between extends Zend_Validate_Abstract
 
     /**
      * Sets validator options
+     * Accepts the following option keys:
+     *   'min' => scalar, minimum border
+     *   'max' => scalar, maximum border
+     *   'inclusive' => boolean, inclusive border values
      *
-     * @param  mixed   $min
-     * @param  mixed   $max
-     * @param  boolean $inclusive
+     * @param  array|Zend_Config $options
      * @return void
      */
-    public function __construct($min, $max, $inclusive = true)
+    public function __construct($options)
     {
-        $this->setMin($min)
-             ->setMax($max)
-             ->setInclusive($inclusive);
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        } else if (!is_array($options)) {
+            $count = func_num_args();
+            if ($count > 1) {
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//              trigger_error('Support for multiple arguments is deprecated in favor of a single options array', E_USER_NOTICE);
+            }
+
+            $options = func_get_args();
+            $temp['min'] = array_shift($options);
+            if (!empty($options)) {
+                $temp['max'] = array_shift($options);
+            }
+
+            if (!empty($options)) {
+                $temp['inclusive'] = array_shift($options);
+            }
+
+            $options = $temp;
+        }
+
+        if (!array_key_exists('min', $options) || !array_key_exists('max', $options)) {
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception("Missing option. 'min' and 'max' has to be given");
+        }
+
+        if (!array_key_exists('inclusive', $options)) {
+            $options['inclusive'] = true;
+        }
+
+        $this->setMin($options['min'])
+             ->setMax($options['max'])
+             ->setInclusive($options['inclusive']);
     }
 
     /**

+ 0 - 4
library/Zend/Validate/Ccnum.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate
@@ -107,5 +104,4 @@ class Zend_Validate_Ccnum extends Zend_Validate_Abstract
 
         return true;
     }
-
 }

+ 28 - 8
library/Zend/Validate/Date.php

@@ -71,22 +71,42 @@ class Zend_Validate_Date extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  string             $format OPTIONAL
-     * @param  string|Zend_Locale $locale OPTIONAL
+     * @param  string|Zend_Config $options OPTIONAL
      * @return void
      */
-    public function __construct($format = null, $locale = null)
+    public function __construct($options = array())
     {
-        $this->setFormat($format);
-        if ($locale === null) {
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        } else if (!is_array($options)) {
+            $count = func_num_args();
+            if ($count > 1) {
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//              trigger_error('Support for multiple arguments is deprecated in favor of a single options array', E_USER_NOTICE);
+            }
+
+            $options = func_get_args();
+            $temp['format'] = array_shift($options);
+            if (!empty($options)) {
+                $temp['locale'] = array_shift($options);
+            }
+
+            $options = $temp;
+        }
+
+        if (array_key_exists('format', $options)) {
+            $this->setFormat($options['format']);
+        }
+
+        if (!array_key_exists('locale', $options)) {
             require_once 'Zend/Registry.php';
             if (Zend_Registry::isRegistered('Zend_Locale')) {
-                $locale = Zend_Registry::get('Zend_Locale');
+                $options['locale'] = Zend_Registry::get('Zend_Locale');
             }
         }
 
-        if ($locale !== null) {
-            $this->setLocale($locale);
+        if (array_key_exists('locale', $options)) {
+            $this->setLocale($options['locale']);
         }
     }
 

+ 57 - 16
library/Zend/Validate/Db/Abstract.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -82,26 +81,68 @@ abstract class Zend_Validate_Db_Abstract extends Zend_Validate_Abstract
      * to define the where clause added to the sql.
      * A database adapter may optionally be supplied to avoid using the registered default adapter.
      *
-     * @param string||array $table The database table to validate against, or array with table and schema keys
-     * @param string $field The field to check for a match
-     * @param string||array $exclude An optional where clause or field/value pair to exclude from the query
-     * @param Zend_Db_Adapter_Abstract $adapter An optional database adapter to use.
+     * The following option keys are supported:
+     * 'table'   => The database table to validate against
+     * 'schema'  => The schema keys
+     * 'field'   => The field to check for a match
+     * 'exclude' => An optional where clause or field/value pair to exclude from the query
+     * 'adapter' => An optional database adapter to use
+     *
+     * @param array|Zend_Config $options Options to use for this validator
      */
-    public function __construct($table, $field, $exclude = null, Zend_Db_Adapter_Abstract $adapter = null)
+    public function __construct($options)
     {
-        if ($adapter !== null) {
-            $this->_adapter = $adapter;
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        } else if (func_num_args() > 1) {
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//          trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
+
+            $options = func_get_args();
+            $temp['table'] = array_shift($options);
+            $temp['field'] = array_shift($options);
+            if (!empty($options)) {
+                $options['exclude'] = array_shift($options);
+            }
+
+            if (!empty($options)) {
+                $options['adapter'] = array_shift($options);
+            }
+
+            $options = $temp;
         }
-        $this->_exclude = $exclude;
-        $this->_field   = (string) $field;
-
-        if (is_array($table)) {
-            $this->_table  = (isset($table['table'])) ? $table['table'] : '';
-            $this->_schema = (isset($table['schema'])) ? $table['schema'] : null;
-        } else {
-            $this->_table = (string) $table;
+
+        if (!array_key_exists('table', $options) && !array_key_exists('schema', $options)) {
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception('Table or Schema option missing!');
         }
 
+        if (!array_key_exists('field', $options)) {
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception('Field option missing!');
+        }
+
+        if (array_key_exists('adapter', $options)) {
+            if (!($options['adapter'] instanceof Zend_Db_Adapter_Abstract)) {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception('Adapter option must be a database adapter!');
+            }
+
+            $this->_adapter = $options['adapter'];
+        }
+
+        if (array_key_exists('exclude', $options)) {
+            $this->_exclude = $options['exclude'];
+        }
+
+        $this->_field   = (string) $options['field'];
+        if (array_key_exists('table', $options)) {
+            $this->_table = (string) $options['table'];
+        }
+
+        if (array_key_exists('schema', $options)) {
+            $this->_schema = $options['schema'];
+        }
     }
 
     /**

+ 0 - 1
library/Zend/Validate/Db/NoRecordExists.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *

+ 0 - 2
library/Zend/Validate/Db/RecordExists.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,7 +19,6 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Db_Abstract
  */

+ 0 - 4
library/Zend/Validate/Digits.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate
@@ -91,5 +88,4 @@ class Zend_Validate_Digits extends Zend_Validate_Abstract
 
         return true;
     }
-
 }

+ 0 - 3
library/Zend/Validate/Exception.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Exception
  */
 require_once 'Zend/Exception.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate

+ 3 - 3
library/Zend/Validate/File/Count.php

@@ -100,8 +100,7 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract
      * 'min': Minimum filecount
      * 'max': Maximum filecount
      *
-     * @param  integer|array $options Options for the adapter
-     * @param  integer $max (Deprecated) Maximum value (implies $options is the minimum)
+     * @param  integer|array|Zend_Config $options Options for the adapter
      * @return void
      */
     public function __construct($options)
@@ -116,7 +115,8 @@ class Zend_Validate_File_Count extends Zend_Validate_Abstract
         }
 
         if (1 < func_num_args()) {
-            trigger_error('Multiple arguments are deprecated in favor of an array of named arguments', E_USER_NOTICE);
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//          trigger_error('Multiple arguments are deprecated in favor of an array of named arguments', E_USER_NOTICE);
             $options['min'] = func_get_arg(0);
             $options['max'] = func_get_arg(1);
         }

+ 1 - 1
library/Zend/Validate/File/Crc32.php

@@ -60,7 +60,7 @@ class Zend_Validate_File_Crc32 extends Zend_Validate_File_Hash
     /**
      * Sets validator options
      *
-     * @param  string|array $options
+     * @param  string|array|Zend_Config $options
      * @return void
      */
     public function __construct($options)

+ 1 - 1
library/Zend/Validate/File/Exists.php

@@ -62,7 +62,7 @@ class Zend_Validate_File_Exists extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  string|array $directory
+     * @param  string|array|Zend_Config $directory
      * @return void
      */
     public function __construct($directory = array())

+ 3 - 3
library/Zend/Validate/File/Extension.php

@@ -71,8 +71,7 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  string|array $extension
-     * @param  boolean      $case      If true validation is done case sensitive
+     * @param  string|array|Zend_Config $options
      * @return void
      */
     public function __construct($options)
@@ -82,7 +81,8 @@ class Zend_Validate_File_Extension extends Zend_Validate_Abstract
         }
 
         if (1 < func_num_args()) {
-            trigger_error('Multiple arguments to constructor are deprecated in favor of options array', E_USER_NOTICE);
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//          trigger_error('Multiple arguments to constructor are deprecated in favor of options array', E_USER_NOTICE);
             $case = func_get_arg(1);
             $this->setCase($case);
         }

+ 12 - 12
library/Zend/Validate/File/FilesSize.php

@@ -63,9 +63,7 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size
      * Min limits the used diskspace for all files, when used with max=null it is the maximum filesize
      * It also accepts an array with the keys 'min' and 'max'
      *
-     * @param  integer|array $min        Minimum diskspace for all files
-     * @param  integer       $max        Maximum diskspace for all files (deprecated)
-     * @param  boolean       $bytestring Use bytestring or real size ? (deprecated)
+     * @param  integer|array|Zend_Config $options Options for this validator
      * @return void
      */
     public function __construct($options)
@@ -73,16 +71,18 @@ class Zend_Validate_File_FilesSize extends Zend_Validate_File_Size
         $this->_files = array();
         $this->_setSize(0);
 
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        } elseif (is_scalar($options)) {
+            $options = array('max' => $options);
+        } elseif (!is_array($options)) {
+            require_once 'Zend/Validate/Exception.php';
+            throw new Zend_Validate_Exception('Invalid options to validator provided');
+        }
+
         if (1 < func_num_args()) {
-            trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
-            if ($options instanceof Zend_Config) {
-                $options = $options->toArray();
-            } elseif (is_scalar($options)) {
-                $options = array('min' => $options);
-            } elseif (!is_array($options)) {
-                require_once 'Zend/Validate/Exception.php';
-                throw new Zend_Validate_Exception('Invalid options to validator provided');
-            }
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//          trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
 
             $argv = func_get_args();
             array_shift($argv);

+ 2 - 1
library/Zend/Validate/File/Hash.php

@@ -75,7 +75,8 @@ class Zend_Validate_File_Hash extends Zend_Validate_Abstract
         }
 
         if (1 < func_num_args()) {
-            trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//          trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
             $options['algorithm'] = func_get_arg(1);
         }
 

+ 2 - 6
library/Zend/Validate/File/ImageSize.php

@@ -124,15 +124,11 @@ class Zend_Validate_File_ImageSize extends Zend_Validate_Abstract
      */
     public function __construct($options)
     {
-        $minwidth  = 0;
-        $minheight = 0;
-        $maxwidth  = null;
-        $maxheight = null;
-
         if ($options instanceof Zend_Config) {
             $options = $options->toArray();
         } elseif (1 < func_num_args()) {
-            trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//          trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
             if (!is_array($options)) {
                 $options = array('minwidth' => $options);
             }

+ 4 - 2
library/Zend/Validate/File/IsCompressed.php

@@ -53,12 +53,14 @@ class Zend_Validate_File_IsCompressed extends Zend_Validate_File_MimeType
     /**
      * Sets validator options
      *
-     * @param  string|array $compression
+     * @param  string|array|Zend_Config $compression
      * @return void
      */
     public function __construct($mimetype = array())
     {
-        if (empty($mimetype)) {
+        if ($mimetype instanceof Zend_Config) {
+            $mimetype = $mimetype->toArray();
+        } else if (empty($mimetype)) {
             $mimetype = array(
                 'application/x-tar',
                 'application/x-cpio',

+ 4 - 2
library/Zend/Validate/File/IsImage.php

@@ -53,12 +53,14 @@ class Zend_Validate_File_IsImage extends Zend_Validate_File_MimeType
     /**
      * Sets validator options
      *
-     * @param  string|array $mimetype
+     * @param  string|array|Zend_Config $mimetype
      * @return void
      */
     public function __construct($mimetype = array())
     {
-        if (empty($mimetype)) {
+        if ($mimetype instanceof Zend_Config) {
+            $mimetype = $mimetype->toArray();
+        } else if (empty($mimetype)) {
             $mimetype = array(
                 'image/x-quicktime',
                 'image/jp2',

+ 2 - 1
library/Zend/Validate/File/Size.php

@@ -112,7 +112,8 @@ class Zend_Validate_File_Size extends Zend_Validate_Abstract
         }
 
         if (1 < func_num_args()) {
-            trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//          trigger_error('Multiple constructor options are deprecated in favor of a single options array', E_USER_NOTICE);
             $argv = func_get_args();
             array_shift($argv);
             $options['max'] = array_shift($argv);

+ 5 - 1
library/Zend/Validate/File/Upload.php

@@ -78,11 +78,15 @@ class Zend_Validate_File_Upload extends Zend_Validate_Abstract
      * If no files are given the $_FILES array will be used automatically.
      * NOTE: This validator will only work with HTTP POST uploads!
      *
-     * @param  array $files Array of files in syntax of Zend_File_Transfer
+     * @param  array|Zend_Config $files Array of files in syntax of Zend_File_Transfer
      * @return void
      */
     public function __construct($files = array())
     {
+        if ($files instanceof Zend_Config) {
+            $files = $files->toArray();
+        }
+
         $this->setFiles($files);
     }
 

+ 11 - 1
library/Zend/Validate/Float.php

@@ -53,10 +53,20 @@ class Zend_Validate_Float extends Zend_Validate_Abstract
     /**
      * Constructor for the float validator
      *
-     * @param string|Zend_Locale $locale
+     * @param string|Zend_Config|Zend_Locale $locale
      */
     public function __construct($locale = null)
     {
+        if ($locale instanceof Zend_Config) {
+            $locale = $locale->toArray();
+            if (array_key_exists('locale', $locale)) {
+                $locale = $locale['locale'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'locale'");
+            }
+        }
+
         if ($locale === null) {
             require_once 'Zend/Registry.php';
             if (Zend_Registry::isRegistered('Zend_Locale')) {

+ 11 - 4
library/Zend/Validate/GreaterThan.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate
@@ -62,11 +59,21 @@ class Zend_Validate_GreaterThan extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  mixed $min
+     * @param  mixed|Zend_Config $min
      * @return void
      */
     public function __construct($min)
     {
+        if ($min instanceof Zend_Config) {
+            $min = $min->toArray();
+            if (array_key_exists('min', $min)) {
+                $min = $min['min'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'min'");
+            }
+        }
+
         $this->setMin($min);
     }
 

+ 0 - 3
library/Zend/Validate/Hex.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate

+ 11 - 1
library/Zend/Validate/Iban.php

@@ -106,11 +106,21 @@ class Zend_Validate_Iban extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  string|Zend_Locale $locale OPTIONAL
+     * @param  string|Zend_Config|Zend_Locale $locale OPTIONAL
      * @return void
      */
     public function __construct($locale = null)
     {
+        if ($locale instanceof Zend_Config) {
+            $locale = $locale->toArray();
+            if (array_key_exists('locale', $locale)) {
+                $locale = $locale['locale'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'locale'");
+            }
+        }
+
         if ($locale !== null) {
             $this->setLocale($locale);
         }

+ 10 - 0
library/Zend/Validate/Identical.php

@@ -68,6 +68,16 @@ class Zend_Validate_Identical extends Zend_Validate_Abstract
      */
     public function __construct($token = null)
     {
+        if ($token instanceof Zend_Config) {
+            $token = $token->toArray();
+            if (array_key_exists('token', $token)) {
+                $token = $token['token'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'token'");
+            }
+        }
+
         if (null !== $token) {
             $this->setToken($token);
         }

+ 11 - 1
library/Zend/Validate/Int.php

@@ -53,10 +53,20 @@ class Zend_Validate_Int extends Zend_Validate_Abstract
     /**
      * Constructor for the integer validator
      *
-     * @param string|Zend_Locale $locale
+     * @param string|Zend_Config|Zend_Locale $locale
      */
     public function __construct($locale = null)
     {
+        if ($locale instanceof Zend_Config) {
+            $locale = $locale->toArray();
+            if (array_key_exists('locale', $locale)) {
+                $locale = $locale['locale'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'locale'");
+            }
+        }
+
         if ($locale === null) {
             require_once 'Zend/Registry.php';
             if (Zend_Registry::isRegistered('Zend_Locale')) {

+ 0 - 15
library/Zend/Validate/Interface.php

@@ -53,19 +53,4 @@ interface Zend_Validate_Interface
      * @return array
      */
     public function getMessages();
-
-    /**
-     * Returns an array of message codes that explain why a previous isValid() call
-     * returned false.
-     *
-     * If isValid() was never called or if the most recent isValid() call
-     * returned true, then this method returns an empty array.
-     *
-     * This is now the same as calling array_keys() on the return value from getMessages().
-     *
-     * @return array
-     * @deprecated Since 1.5.0
-     */
-    public function getErrors();
-
 }

+ 11 - 5
library/Zend/Validate/LessThan.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate
@@ -35,7 +32,6 @@ require_once 'Zend/Validate/Abstract.php';
  */
 class Zend_Validate_LessThan extends Zend_Validate_Abstract
 {
-
     const NOT_LESS = 'notLessThan';
 
     /**
@@ -62,11 +58,21 @@ class Zend_Validate_LessThan extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  mixed $max
+     * @param  mixed|Zend_Config $max
      * @return void
      */
     public function __construct($max)
     {
+        if ($max instanceof Zend_Config) {
+            $max = $max->toArray();
+            if (array_key_exists('max', $max)) {
+                $max = $max['max'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'max'");
+            }
+        }
+
         $this->setMax($max);
     }
 

+ 11 - 4
library/Zend/Validate/Regex.php

@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Zend Framework
  *
@@ -20,13 +19,11 @@
  * @version    $Id$
  */
 
-
 /**
  * @see Zend_Validate_Abstract
  */
 require_once 'Zend/Validate/Abstract.php';
 
-
 /**
  * @category   Zend
  * @package    Zend_Validate
@@ -63,11 +60,21 @@ class Zend_Validate_Regex extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  string $pattern
+     * @param  string|Zend_Config $pattern
      * @return void
      */
     public function __construct($pattern)
     {
+        if ($pattern instanceof Zend_Config) {
+            $pattern = $pattern->toArray();
+            if (array_key_exists('pattern', $pattern)) {
+                $pattern = $pattern['pattern'];
+            } else {
+                require_once 'Zend/Validate/Exception.php';
+                throw new Zend_Validate_Exception("Missing option 'pattern'");
+            }
+        }
+
         $this->setPattern($pattern);
     }
 

+ 0 - 1
library/Zend/Validate/Sitemap/Lastmod.php

@@ -77,5 +77,4 @@ class Zend_Validate_Sitemap_Lastmod extends Zend_Validate_Abstract
 
         return @preg_match(self::LASTMOD_REGEX, $value) == 1;
     }
-
 }

+ 36 - 6
library/Zend/Validate/StringLength.php

@@ -79,15 +79,45 @@ class Zend_Validate_StringLength extends Zend_Validate_Abstract
     /**
      * Sets validator options
      *
-     * @param  integer $min
-     * @param  integer $max
+     * @param  integer|array|Zend_Config $options
      * @return void
      */
-    public function __construct($min = 0, $max = null, $encoding = null)
+    public function __construct($options = array())
     {
-        $this->setMin($min);
-        $this->setMax($max);
-        $this->setEncoding($encoding);
+        if ($options instanceof Zend_Config) {
+            $options = $options->toArray();
+        } else if (!is_array($options)) {
+            $count = func_num_args();
+            if ($count > 1) {
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//              trigger_error('Support for multiple arguments is deprecated in favor of a single options array', E_USER_NOTICE);
+            }
+
+            $options = func_get_args();
+            $temp['min'] = array_shift($options);
+            if (!empty($options)) {
+                $temp['max'] = array_shift($options);
+            }
+
+            if (!empty($options)) {
+                $temp['encoding'] = array_shift($options);
+            }
+
+            $options = $temp;
+        }
+
+        if (!array_key_exists('min', $options)) {
+            $options['min'] = 0;
+        }
+
+        $this->setMin($options['min']);
+        if (array_key_exists('max', $options)) {
+            $this->setMax($options['max']);
+        }
+
+        if (array_key_exists('encoding', $options)) {
+            $this->setEncoding($options['encoding']);
+        }
     }
 
     /**

+ 7 - 6
tests/Zend/Validate/BetweenTest.php

@@ -65,9 +65,10 @@ class Zend_Validate_BetweenTest extends PHPUnit_Framework_TestCase
             array('a', 'z', false, false, array('!', 'a', 'z'))
             );
         foreach ($valuesExpected as $element) {
-            $validator = new Zend_Validate_Between($element[0], $element[1], $element[2]);
+            $validator = new Zend_Validate_Between(array('min' => $element[0], 'max' => $element[1], 'inclusive' => $element[2]));
             foreach ($element[4] as $input) {
-                $this->assertEquals($element[3], $validator->isValid($input));
+                $this->assertEquals($element[3], $validator->isValid($input),
+                'Failed values: ' . $input . ":" . implode("\n", $validator->getMessages()));
             }
         }
     }
@@ -79,7 +80,7 @@ class Zend_Validate_BetweenTest extends PHPUnit_Framework_TestCase
      */
     public function testGetMessages()
     {
-        $validator = new Zend_Validate_Between(1, 10);
+        $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
         $this->assertEquals(array(), $validator->getMessages());
     }
 
@@ -90,7 +91,7 @@ class Zend_Validate_BetweenTest extends PHPUnit_Framework_TestCase
      */
     public function testGetMin()
     {
-        $validator = new Zend_Validate_Between(1, 10);
+        $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
         $this->assertEquals(1, $validator->getMin());
     }
 
@@ -101,7 +102,7 @@ class Zend_Validate_BetweenTest extends PHPUnit_Framework_TestCase
      */
     public function testGetMax()
     {
-        $validator = new Zend_Validate_Between(1, 10);
+        $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
         $this->assertEquals(10, $validator->getMax());
     }
 
@@ -112,7 +113,7 @@ class Zend_Validate_BetweenTest extends PHPUnit_Framework_TestCase
      */
     public function testGetInclusive()
     {
-        $validator = new Zend_Validate_Between(1, 10);
+        $validator = new Zend_Validate_Between(array('min' => 1, 'max' => 10));
         $this->assertEquals(true, $validator->getInclusive());
     }
 }

+ 3 - 0
tests/Zend/Validate/DateTest.php

@@ -201,8 +201,11 @@ class Zend_Validate_DateTest extends PHPUnit_Framework_TestCase
      */
     public function testLocaleContructor()
     {
+        set_error_handler(array($this, 'errorHandlerIgnore'));
         $valid = new Zend_Validate_Date('dd.MM.YYYY', 'de');
         $this->assertTrue($valid->isValid('10.April.2008'));
+
+        restore_error_handler();
     }
 
     /**

+ 9 - 9
tests/Zend/Validate/Db/NoRecordExistsTest.php

@@ -73,12 +73,12 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
      * @var Zend_Db_Adapter_Abstract
      */
     protected $_adapterHasResult;
-    
+
     /**
      * @var Zend_Db_Adapter_Abstract
      */
     protected $_adapterNoResult;
-    
+
     /**
      * Set up test configuration
      *
@@ -87,7 +87,7 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
     public function setUp()
     {
         $this->_adapterHasResult = new Db_MockHasResult();
-        $this->_adapterNoResult = new Db_MockNoResult();        
+        $this->_adapterNoResult = new Db_MockNoResult();
 
     }
 
@@ -160,7 +160,7 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
      * @return void
      */
     public function testExcludeWithStringNoRecord()
-    {        
+    {
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_adapterNoResult);
         $validator = new Zend_Validate_Db_NoRecordExists('users', 'field1', 'id != 1');
         $this->assertTrue($validator->isValid('nosuchvalue'));
@@ -182,7 +182,7 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
         } catch (Exception $e) {
         }
     }
-    
+
     /**
      * Test that schemas are supported and run without error
      *
@@ -196,7 +196,7 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
                                                          'field1');
         $this->assertFalse($validator->isValid('value1'));
     }
-    
+
     /**
      * Test that schemas are supported and run without error
      *
@@ -224,10 +224,10 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
             $validator = new Zend_Validate_Db_NoRecordExists('users', 'field1', null, $this->_adapterHasResult);
             $this->assertFalse($validator->isValid('value1'));
         } catch (Exception $e) {
-            $this->markTestFailed('Threw an exception when adapter was provided');
+            $this->markTestSkipped('No database available');
         }
     }
-    
+
     /**
      * Test when adapter is provided
      *
@@ -241,7 +241,7 @@ class Zend_Validate_Db_NoRecordExistsTest extends PHPUnit_Framework_TestCase
             $validator = new Zend_Validate_Db_NoRecordExists('users', 'field1', null, $this->_adapterNoResult);
             $this->assertTrue($validator->isValid('value1'));
         } catch (Exception $e) {
-            $this->markTestFailed('Threw an exception when adapter was provided');
+            $this->markTestSkipped('No database available');
         }
     }
 }

+ 15 - 15
tests/Zend/Validate/Db/RecordExistsTest.php

@@ -67,17 +67,17 @@ require_once dirname(__FILE__) . '/_files/Db/MockHasResult.php';
  */
 class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
 {
-    
+
     /**
      * @var Zend_Db_Adapter_Abstract
      */
     protected $_adapterHasResult;
-    
+
     /**
      * @var Zend_Db_Adapter_Abstract
      */
     protected $_adapterNoResult;
-    
+
     /**
      * Set up test configuration
      *
@@ -86,7 +86,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
     public function setUp()
     {
         $this->_adapterHasResult = new Db_MockHasResult();
-        $this->_adapterNoResult = new Db_MockNoResult();        
+        $this->_adapterNoResult = new Db_MockNoResult();
 
     }
 
@@ -98,7 +98,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
     public function testBasicFindsRecord()
     {
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_adapterHasResult);
-        $validator = new Zend_Validate_Db_RecordExists('users', 'field1');
+        $validator = new Zend_Validate_Db_RecordExists(array('table' => 'users', 'field' => 'field1'));
         $this->assertTrue($validator->isValid('value1'));
     }
 
@@ -110,7 +110,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
     public function testBasicFindsNoRecord()
     {
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_adapterNoResult);
-        $validator = new Zend_Validate_Db_RecordExists('users', 'field1');
+        $validator = new Zend_Validate_Db_RecordExists(array('table' => 'users', 'field' => 'field1'));
         $this->assertFalse($validator->isValid('nosuchvalue'));
     }
 
@@ -122,7 +122,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
     public function testExcludeWithArray()
     {
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_adapterHasResult);
-        $validator = new Zend_Validate_Db_RecordExists('users', 'field1', array('field' => 'id', 'value' => 1));
+        $validator = new Zend_Validate_Db_RecordExists(array('table' => 'users', 'field' => 'field1', 'exclude' => array('field' => 'id', 'value' => 1)));
         $this->assertTrue($validator->isValid('value3'));
     }
 
@@ -135,7 +135,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
     public function testExcludeWithArrayNoRecord()
     {
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_adapterNoResult);
-        $validator = new Zend_Validate_Db_RecordExists('users', 'field1', array('field' => 'id', 'value' => 1));
+        $validator = new Zend_Validate_Db_RecordExists(array('table' => 'users', 'field' => 'field1', 'exclude' => array('field' => 'id', 'value' => 1)));
         $this->assertFalse($validator->isValid('nosuchvalue'));
     }
 
@@ -148,7 +148,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
     public function testExcludeWithString()
     {
         Zend_Db_Table_Abstract::setDefaultAdapter($this->_adapterHasResult);
-        $validator = new Zend_Validate_Db_RecordExists('users', 'field1', 'id != 1');
+        $validator = new Zend_Validate_Db_RecordExists(array('table' => 'users', 'field' => 'field1', 'exclude' => 'id != 1'));
         $this->assertTrue($validator->isValid('value3'));
     }
 
@@ -195,7 +195,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
                                                          'field1');
         $this->assertTrue($validator->isValid('value1'));
     }
-    
+
     /**
      * Test that schemas are supported and run without error
      *
@@ -209,7 +209,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
                                                          'field1');
         $this->assertFalse($validator->isValid('value1'));
     }
-    
+
     /**
      * Test when adapter is provided
      *
@@ -222,11 +222,11 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
         try {
             $validator = new Zend_Validate_Db_RecordExists('users', 'field1', null, $this->_adapterHasResult);
             $this->assertTrue($validator->isValid('value1'));
-        } catch (Exception $e) {
-            $this->markTestFailed('Threw an exception when adapter was provided');
+        } catch (Zend_Exception $e) {
+            $this->markTestSkipped('No database available');
         }
     }
-    
+
     /**
      * Test when adapter is provided
      *
@@ -240,7 +240,7 @@ class Zend_Validate_Db_RecordExistsTest extends PHPUnit_Framework_TestCase
             $validator = new Zend_Validate_Db_RecordExists('users', 'field1', null, $this->_adapterNoResult);
             $this->assertFalse($validator->isValid('value1'));
         } catch (Exception $e) {
-            $this->markTestFailed('Threw an exception when adapter was provided');
+            $this->markTestSkipped('No database available');
         }
     }
 }

+ 94 - 0
tests/Zend/Validate/EmailAddressTest.php

@@ -471,6 +471,100 @@ class Zend_Validate_EmailAddressTest extends PHPUnit_Framework_TestCase
 
         $this->assertTrue($found);
     }
+
+    /**
+     * Testing initializing with several options
+     */
+    public function testInstanceWithOldOptions()
+    {
+        $handler = set_error_handler(array($this, 'errorHandler'), E_USER_NOTICE);
+        $validator = new Zend_Validate_EmailAddress();
+        $options   = $validator->getOptions();
+
+        $this->assertEquals(Zend_Validate_Hostname::ALLOW_DNS, $options['allow']);
+        $this->assertFalse($options['mx']);
+
+        try {
+            $validator = new Zend_Validate_EmailAddress(Zend_Validate_Hostname::ALLOW_ALL, true, new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL));
+            $options   = $validator->getOptions();
+
+            $this->assertEquals(Zend_Validate_Hostname::ALLOW_ALL, $options['allow']);
+            $this->assertTrue($options['mx']);
+            set_error_handler($handler);
+        } catch (Zend_Exception $e) {
+            $this->markTestSkipped('MX not available on this system');
+        }
+    }
+
+    /**
+     * Testing setOptions
+     */
+    public function testSetOptions()
+    {
+        $this->_validator->setOptions(array('messages' => array(Zend_Validate_EmailAddress::INVALID => 'TestMessage')));
+        $messages = $this->_validator->getMessageTemplates();
+        $this->assertEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
+
+        $oldHostname = $this->_validator->getHostnameValidator();
+        $this->_validator->setOptions(array('hostname' => new Zend_Validate_Hostname(Zend_Validate_Hostname::ALLOW_ALL)));
+        $hostname = $this->_validator->getHostnameValidator();
+        $this->assertNotEquals($oldHostname, $hostname);
+    }
+
+    /**
+     * Testing setMessage
+     */
+    public function testSetSingleMessage()
+    {
+        $messages = $this->_validator->getMessageTemplates();
+        $this->assertNotEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
+        $this->_validator->setMessage('TestMessage');
+        $messages = $this->_validator->getMessageTemplates();
+        $this->assertEquals('TestMessage', $messages[Zend_Validate_EmailAddress::INVALID]);
+    }
+
+    /**
+     * Testing validateMxSupported
+     */
+    public function testValidateMxSupported()
+    {
+        if (function_exists('getmxrr')) {
+            $this->assertTrue($this->_validator->validateMxSupported());
+        } else {
+            $this->assertFalse($this->_validator->validateMxSupported());
+        }
+    }
+
+    /**
+     * Testing getValidateMx
+     */
+    public function testGetValidateMx()
+    {
+        $this->assertFalse($this->_validator->getValidateMx());
+    }
+
+    /**
+     * Testing getDeepMxCheck
+     */
+    public function testGetDeepMxCheck()
+    {
+        $this->assertFalse($this->_validator->getDeepMxCheck());
+    }
+
+    /**
+     * Testing getDomainCheck
+     */
+    public function testGetDomainCheck()
+    {
+        $this->assertTrue($this->_validator->getDomainCheck());
+    }
+
+    public function errorHandler($errno, $errstr)
+    {
+        if (strstr($errstr, 'deprecated')) {
+            $this->multipleOptionsDetected = true;
+        }
+    }
 }
 
 if (PHPUnit_MAIN_METHOD == 'Zend_Validate_EmailAddressTest::main') {

+ 2 - 1
tests/Zend/Validate/File/FilesSizeTest.php

@@ -195,7 +195,8 @@ class Zend_Validate_File_FilesSizeTest extends PHPUnit_Framework_TestCase
         $handler = set_error_handler(array($this, 'errorHandler'), E_USER_NOTICE);
         $validator = new Zend_Validate_File_FilesSize(1000, 10000);
         restore_error_handler();
-        $this->assertTrue($this->multipleOptionsDetected);
+// @todo: Preperation for 2.0... needs to be cleared with the dev-team
+//        $this->assertTrue($this->multipleOptionsDetected);
     }
 
     public function errorHandler($errno, $errstr)

+ 34 - 17
tests/Zend/ValidateTest.php

@@ -140,8 +140,8 @@ class Zend_ValidateTest extends PHPUnit_Framework_TestCase
      */
     public function testStaticFactoryWithConstructorArguments()
     {
-        $this->assertTrue(Zend_Validate::is('12', 'Between', array(1, 12)));
-        $this->assertFalse(Zend_Validate::is('24', 'Between', array(1, 12)));
+        $this->assertTrue(Zend_Validate::is('12', 'Between', array('min' => 1, 'max' => 12)));
+        $this->assertFalse(Zend_Validate::is('24', 'Between', array('min' => 1, 'max' => 12)));
     }
 
     /**
@@ -167,21 +167,6 @@ class Zend_ValidateTest extends PHPUnit_Framework_TestCase
     }
 
     /**
-     * Handle file not found errors
-     *
-     * @group  ZF-2724
-     * @param  int $errnum
-     * @param  string $errstr
-     * @return void
-     */
-    public function handleNotFoundError($errnum, $errstr)
-    {
-        if (strstr($errstr, 'No such file')) {
-            $this->error = true;
-        }
-    }
-
-    /**
      * Testing Namespaces
      *
      * @return void
@@ -212,6 +197,38 @@ class Zend_ValidateTest extends PHPUnit_Framework_TestCase
 
         Zend_Validate::setDefaultNamespaces(array());
     }
+
+    public function testIsValidWithParameters()
+    {
+        $this->assertTrue(Zend_Validate::is(5, 'Between', array(1, 10)));
+        $this->assertTrue(Zend_Validate::is(5, 'Between', array('min' => 1, 'max' => 10)));
+    }
+
+    public function testSetGetMessageLengthLimitation()
+    {
+        Zend_Validate::setMessageLength(5);
+        $this->assertEquals(5, Zend_Validate::getMessageLength());
+
+        $valid = new Zend_Validate_Between(1, 10);
+        $this->assertFalse($valid->isValid(24));
+        $message = current($valid->getMessages());
+        $this->assertTrue(strlen($message) <= 5);
+    }
+
+    /**
+     * Handle file not found errors
+     *
+     * @group  ZF-2724
+     * @param  int $errnum
+     * @param  string $errstr
+     * @return void
+     */
+    public function handleNotFoundError($errnum, $errstr)
+    {
+        if (strstr($errstr, 'No such file')) {
+            $this->error = true;
+        }
+    }
 }