Zend_Validate-Between.xml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.validate.set.between">
  4. <title>Between</title>
  5. <para>
  6. <classname>Zend_Validate_Between</classname> allows you to validate if a given value is
  7. between two other values.
  8. </para>
  9. <note>
  10. <title>Zend_Validate_Between supports only number validation</title>
  11. <para>
  12. It should be noted that <classname>Zend_Validate_Between</classname> supports only the
  13. validation of numbers. Strings or dates can not be validated with this validator.
  14. </para>
  15. </note>
  16. <sect3 id="zend.validate.set.between.options">
  17. <title>Supported options for Zend_Validate_Between</title>
  18. <para>
  19. The following options are supported for <classname>Zend_Validate_Between</classname>:
  20. </para>
  21. <itemizedlist>
  22. <listitem>
  23. <para>
  24. <emphasis><property>inclusive</property></emphasis>: Defines if the validation
  25. is inclusive the minimum and maximum border values or exclusive. It defaults
  26. to <constant>TRUE</constant>.
  27. </para>
  28. </listitem>
  29. <listitem>
  30. <para>
  31. <emphasis><property>max</property></emphasis>: Sets the maximum border for the
  32. validation.
  33. </para>
  34. </listitem>
  35. <listitem>
  36. <para>
  37. <emphasis><property>min</property></emphasis>: Sets the minimum border for the
  38. validation.
  39. </para>
  40. </listitem>
  41. </itemizedlist>
  42. </sect3>
  43. <sect3 id="zend.validate.set.between.basic">
  44. <title>Default behaviour for Zend_Validate_Between</title>
  45. <para>
  46. Per default this validator checks if a value is between <property>min</property> and
  47. <property>max</property> where both border values are allowed as value.
  48. </para>
  49. <programlisting language="php"><![CDATA[
  50. $valid = new Zend_Validate_Between(array('min' => 0, 'max' => 10));
  51. $value = 10;
  52. $result = $valid->isValid($value);
  53. // returns true
  54. ]]></programlisting>
  55. <para>
  56. In the above example the result is <constant>TRUE</constant> due to the reason that per
  57. default the search is inclusively the border values. This means in our case that any
  58. value from '0' to '10' is allowed. And values like '-1' and '11' will return
  59. <constant>FALSE</constant>.
  60. </para>
  61. </sect3>
  62. <sect3 id="zend.validate.set.between.inclusively">
  63. <title>Validation exclusive the border values</title>
  64. <para>
  65. Sometimes it is useful to validate a value by excluding the border values. See the
  66. following example:
  67. </para>
  68. <programlisting language="php"><![CDATA[
  69. $valid = new Zend_Validate_Between(
  70. array(
  71. 'min' => 0,
  72. 'max' => 10,
  73. 'inclusive' => false
  74. )
  75. );
  76. $value = 10;
  77. $result = $valid->isValid($value);
  78. // returns false
  79. ]]></programlisting>
  80. <para>
  81. The example is almost equal to our first example but we excluded the border value. Now
  82. the values '0' and '10' are no longer allowed and will return
  83. <constant>FALSE</constant>.
  84. </para>
  85. </sect3>
  86. </sect2>
  87. <!--
  88. vim:se ts=4 sw=4 et:
  89. -->