Zend_Validate-Set.xml 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.validate.set" xmlns:xi="http://www.w3.org/2001/XInclude">
  4. <title>Standard Validation Classes</title>
  5. <para>
  6. Zend Framework comes with a standard set of validation classes, which are ready for you to
  7. use.
  8. </para>
  9. <sect2 id="zend.validate.set.alnum">
  10. <title>Alnum</title>
  11. <para>
  12. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains only alphabetic
  13. and digit characters. This validator includes an option to also consider white space
  14. characters as valid.
  15. </para>
  16. <note>
  17. <para>
  18. The alphabetic characters mean characters that makes up words in each language.
  19. However, the English alphabet is treated as the alphabetic characters in following
  20. languages: Chinese, Japanese, Korean. The language is specified by <classname>Zend_Locale</classname>.
  21. </para>
  22. </note>
  23. </sect2>
  24. <sect2 id="zend.validate.set.alpha">
  25. <title>Alpha</title>
  26. <para>
  27. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains only alphabetic
  28. characters. This validator includes an option to also consider white space characters
  29. as valid.
  30. </para>
  31. </sect2>
  32. <xi:include href="Zend_Validate-Barcode.xml" />
  33. <sect2 id="zend.validate.set.between">
  34. <title>Between</title>
  35. <para>
  36. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is between the minimum and
  37. maximum boundary values. The comparison is inclusive by default (<varname>$value</varname> may
  38. equal a boundary value), though this may be overridden in order to do a strict
  39. comparison, where <varname>$value</varname> must be strictly greater than the minimum and
  40. strictly less than the maximum.
  41. </para>
  42. </sect2>
  43. <xi:include href="Zend_Validate-Callback.xml" />
  44. <xi:include href="Zend_Validate-CreditCard.xml" />
  45. <sect2 id="zend.validate.set.ccnum">
  46. <title>Ccnum</title>
  47. <para>
  48. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> follows the Luhn algorithm
  49. (mod-10 checksum) for credit card numbers.
  50. </para>
  51. <note>
  52. <para>
  53. The <classname>Ccnum</classname> validator has been deprecated in favor of the
  54. <classname>CreditCard</classname> validator. For security reasons you should use
  55. CreditCard instead of Ccnum.
  56. </para>
  57. </note>
  58. </sect2>
  59. <sect2 id="zend.validate.set.date">
  60. <title>Date</title>
  61. <para>
  62. Returns <constant>TRUE</constant> if <varname>$value</varname> is a valid date of the
  63. format 'YYYY-MM-DD'. If the optional <property>locale</property> option is set then the
  64. date will be validated according to the set locale. And if the optional
  65. <property>format</property> option is set this format is used for the validation. for
  66. details about the optional parameters see <link
  67. linkend="zend.date.others.comparison.table">Zend_Date::isDate()</link>.
  68. </para>
  69. </sect2>
  70. <xi:include href="Zend_Validate-Db.xml" />
  71. <sect2 id="zend.validate.set.digits">
  72. <title>Digits</title>
  73. <para>
  74. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> only contains digit
  75. characters.
  76. </para>
  77. </sect2>
  78. <xi:include href="Zend_Validate-EmailAddress.xml" />
  79. <sect2 id="zend.validate.set.float">
  80. <title>Float</title>
  81. <para>
  82. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is a floating-point value.
  83. Since Zend Framework 1.8 this validator takes into account the actual locale from
  84. browser, environment or application wide set locale. You can of course use the
  85. get/setLocale accessors to change the used locale or give it while creating a instance
  86. of this validator.
  87. </para>
  88. </sect2>
  89. <sect2 id="zend.validate.set.greater_than">
  90. <title>GreaterThan</title>
  91. <para>
  92. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is greater than the minimum
  93. boundary.
  94. </para>
  95. </sect2>
  96. <sect2 id="zend.validate.set.hex">
  97. <title>Hex</title>
  98. <para>
  99. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains only hexadecimal
  100. digit characters.
  101. </para>
  102. </sect2>
  103. <xi:include href="Zend_Validate-Hostname.xml" />
  104. <sect2 id="zend.validate.set.iban">
  105. <title>Iban</title>
  106. <para>
  107. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains a valid IBAN
  108. (International Bank Account Number). IBAN numbers are validated against the country
  109. where they are used and by a checksum.
  110. </para>
  111. <para>
  112. There are two ways to validate IBAN numbers. As first way you can give a locale which
  113. represents a country. Any given IBAN number will then be validated against this country.
  114. </para>
  115. <programlisting language="php"><![CDATA[
  116. $validator = new Zend_Validate_Iban('de_AT');
  117. $iban = 'AT611904300234573201';
  118. if ($validator->isValid($iban)) {
  119. // IBAN appears to be valid
  120. } else {
  121. // IBAN is invalid
  122. foreach ($validator->getMessages() as $message) {
  123. echo "$message\n";
  124. }
  125. }
  126. ]]></programlisting>
  127. <para>
  128. This should be done when you want to validate IBAN numbers for a single countries. The
  129. simpler way of validation is not to give a locale like shown in the next example.
  130. </para>
  131. <programlisting language="php"><![CDATA[
  132. $validator = new Zend_Validate_Iban();
  133. $iban = 'AT611904300234573201';
  134. if ($validator->isValid($iban)) {
  135. // IBAN appears to be valid
  136. } else {
  137. // IBAN is invalid
  138. }
  139. ]]></programlisting>
  140. <para>
  141. But this shows one big problem: When you have to accept only IBAN numbers from one
  142. single country, for example france, then IBAN numbers from other countries would also be
  143. valid. Therefor just remember: When you have to validate a IBAN number against a defined
  144. country you should give the locale. And when you accept all IBAN numbers regardless of
  145. any country omit the locale for simplicity.
  146. </para>
  147. </sect2>
  148. <xi:include href="Zend_Validate-Identical.xml" />
  149. <xi:include href="Zend_Validate-InArray.xml" />
  150. <sect2 id="zend.validate.set.int">
  151. <title>Int</title>
  152. <para>
  153. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is a valid integer. Since
  154. Zend Framework 1.8 this validator takes into account the actual locale from browser,
  155. environment or application wide set locale. You can of course use the get/setLocale
  156. accessors to change the used locale or give it while creating a instance of this
  157. validator.
  158. </para>
  159. </sect2>
  160. <xi:include href="Zend_Validate-Ip.xml" />
  161. <sect2 id="zend.validate.set.less_than">
  162. <title>LessThan</title>
  163. <para>
  164. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is less than
  165. the maximum boundary.
  166. </para>
  167. </sect2>
  168. <xi:include href="Zend_Validate-NotEmpty.xml" />
  169. <xi:include href="Zend_Validate-PostCode.xml" />
  170. <sect2 id="zend.validate.set.regex">
  171. <title>Regex</title>
  172. <para>
  173. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> matches
  174. against a regular expression pattern.
  175. </para>
  176. </sect2>
  177. <xi:include href="Zend_Validate-Sitemap.xml" />
  178. <sect2 id="zend.validate.set.string_length">
  179. <title>StringLength</title>
  180. <para>
  181. Returns <constant>TRUE</constant> if and only if the string length of
  182. <varname>$value</varname> is at least a minimum and no greater than a maximum (when the
  183. max option is not <constant>NULL</constant>). The <methodname>setMin()</methodname>
  184. method throws an exception if the minimum length is set to a value greater than the set
  185. maximum length, and the <methodname>setMax()</methodname> method throws an exception if
  186. the maximum length is set to a value less than the set minimum length. This class
  187. supports UTF-8 and other character encodings, based on the current value of <ulink
  188. url="http://www.php.net/manual/en/ref.iconv.php#iconv.configuration">iconv.internal_encoding</ulink>.
  189. If you need a different encoding you can set it with the accessor methods getEncoding
  190. and setEncoding.
  191. </para>
  192. </sect2>
  193. </sect1>
  194. <!--
  195. vim:se ts=4 sw=4 et:
  196. -->