Zend_Validate-Set.xml 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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 <code>$value</code> 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 Zend_Locale.
  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 <code>$value</code> contains only alphabetic
  28. characters. This validator includes an option to also consider white space characters
  29. as valid.
  30. </para>
  31. </sect2>
  32. <sect2 id="zend.validate.set.barcode">
  33. <title>Barcode</title>
  34. <para>
  35. This validator is instantiated with a barcode type against which you wish to validate a
  36. barcode value. It currently supports "<code>UPC-A</code>" (Universal Product Code) and
  37. "<code>EAN-13</code>" (European Article Number) barcode types, and the
  38. <code>isValid()</code> method returns true if and only if the input successfully
  39. validates against the barcode validation algorithm. You should remove all characters
  40. other than the digits zero through nine (0-9) from the input value before passing it on
  41. to the validator.
  42. </para>
  43. </sect2>
  44. <sect2 id="zend.validate.set.between">
  45. <title>Between</title>
  46. <para>
  47. Returns <constant>TRUE</constant> if and only if <code>$value</code> is between the minimum and
  48. maximum boundary values. The comparison is inclusive by default (<code>$value</code> may
  49. equal a boundary value), though this may be overridden in order to do a strict
  50. comparison, where <code>$value</code> must be strictly greater than the minimum and
  51. strictly less than the maximum.
  52. </para>
  53. </sect2>
  54. <sect2 id="zend.validate.set.ccnum">
  55. <title>Ccnum</title>
  56. <para>
  57. Returns <constant>TRUE</constant> if and only if <code>$value</code> follows the Luhn algorithm
  58. (mod-10 checksum) for credit card numbers.
  59. </para>
  60. </sect2>
  61. <sect2 id="zend.validate.set.date">
  62. <title>Date</title>
  63. <para>
  64. Returns <constant>TRUE</constant> if <code>$value</code> is a valid date of the format
  65. <code>YYYY-MM-DD</code>. If the optional <code>locale</code> option is set then the date
  66. will be validated according to the set locale. And if the optional <code>format</code>
  67. option is set this format is used for the validation. for details about the optional
  68. parameters see <link
  69. linkend="zend.date.others.comparison.table">Zend_Date::isDate()</link>.
  70. </para>
  71. </sect2>
  72. <xi:include href="Zend_Validate-Db.xml" />
  73. <sect2 id="zend.validate.set.digits">
  74. <title>Digits</title>
  75. <para>
  76. Returns <constant>TRUE</constant> if and only if <code>$value</code> only contains digit
  77. characters.
  78. </para>
  79. </sect2>
  80. <xi:include href="Zend_Validate-EmailAddress.xml" />
  81. <sect2 id="zend.validate.set.float">
  82. <title>Float</title>
  83. <para>
  84. Returns <constant>TRUE</constant> if and only if <code>$value</code> is a floating-point value.
  85. Since Zend Framework 1.8 this validator takes into account the actual locale from
  86. browser, environment or application wide set locale. You can of course use the
  87. get/setLocale accessors to change the used locale or give it while creating a instance
  88. of this validator.
  89. </para>
  90. </sect2>
  91. <sect2 id="zend.validate.set.greater_than">
  92. <title>GreaterThan</title>
  93. <para>
  94. Returns <constant>TRUE</constant> if and only if <code>$value</code> is greater than the minimum
  95. boundary.
  96. </para>
  97. </sect2>
  98. <sect2 id="zend.validate.set.hex">
  99. <title>Hex</title>
  100. <para>
  101. Returns <constant>TRUE</constant> if and only if <code>$value</code> contains only hexadecimal
  102. digit characters.
  103. </para>
  104. </sect2>
  105. <xi:include href="Zend_Validate-Hostname.xml" />
  106. <sect2 id="zend.validate.set.iban">
  107. <title>Iban</title>
  108. <para>
  109. Returns <constant>TRUE</constant> if and only if <code>$value</code> contains a valid IBAN
  110. (International Bank Account Number). IBAN numbers are validated against the country
  111. where they are used and by a checksum.
  112. </para>
  113. <para>
  114. There are two ways to validate IBAN numbers. As first way you can give a locale which
  115. represents a country. Any given IBAN number will then be validated against this country.
  116. </para>
  117. <programlisting language="php"><![CDATA[
  118. $validator = new Zend_Validate_Iban('de_AT');
  119. $iban = 'AT611904300234573201';
  120. if ($validator->isValid($iban)) {
  121. // IBAN appears to be valid
  122. } else {
  123. // IBAN is invalid
  124. foreach ($validator->getMessages() as $message) {
  125. echo "$message\n";
  126. }
  127. }
  128. ]]></programlisting>
  129. <para>
  130. This should be done when you want to validate IBAN numbers for a single countries. The
  131. simpler way of validation is not to give a locale like shown in the next example.
  132. </para>
  133. <programlisting language="php"><![CDATA[
  134. $validator = new Zend_Validate_Iban();
  135. $iban = 'AT611904300234573201';
  136. if ($validator->isValid($iban)) {
  137. // IBAN appears to be valid
  138. } else {
  139. // IBAN is invalid
  140. }
  141. ]]></programlisting>
  142. <para>
  143. But this shows one big problem: When you have to accept only IBAN numbers from one
  144. single country, for example france, then IBAN numbers from other countries would also be
  145. valid. Therefor just remember: When you have to validate a IBAN number against a defined
  146. country you should give the locale. And when you accept all IBAN numbers regardless of
  147. any country omit the locale for simplicity.
  148. </para>
  149. </sect2>
  150. <sect2 id="zend.validate.set.in_array">
  151. <title>InArray</title>
  152. <para>
  153. Returns <constant>TRUE</constant> if and only if a "needle" <code>$value</code> is contained in
  154. a "haystack" array. If the strict option is <constant>TRUE</constant>, then the type of
  155. <code>$value</code> is also checked.
  156. </para>
  157. </sect2>
  158. <sect2 id="zend.validate.set.int">
  159. <title>Int</title>
  160. <para>
  161. Returns <constant>TRUE</constant> if and only if <code>$value</code> is a valid integer. Since
  162. Zend Framework 1.8 this validator takes into account the actual locale from browser,
  163. environment or application wide set locale. You can of course use the get/setLocale
  164. accessors to change the used locale or give it while creating a instance of this
  165. validator.
  166. </para>
  167. </sect2>
  168. <sect2 id="zend.validate.set.ip">
  169. <title>Ip</title>
  170. <para>
  171. Returns <constant>TRUE</constant> if and only if <code>$value</code> is a valid IP address.
  172. </para>
  173. </sect2>
  174. <sect2 id="zend.validate.set.less_than">
  175. <title>LessThan</title>
  176. <para>
  177. Returns <constant>TRUE</constant> if and only if <code>$value</code> is less than the maximum
  178. boundary.
  179. </para>
  180. </sect2>
  181. <sect2 id="zend.validate.set.not_empty">
  182. <title>NotEmpty</title>
  183. <para>
  184. Returns <constant>TRUE</constant> if and only if <code>$value</code> is not an empty value.
  185. </para>
  186. </sect2>
  187. <sect2 id="zend.validate.set.regex">
  188. <title>Regex</title>
  189. <para>
  190. Returns <constant>TRUE</constant> if and only if <code>$value</code> matches against a regular
  191. expression pattern.
  192. </para>
  193. </sect2>
  194. <xi:include href="Zend_Validate-Sitemap.xml" />
  195. <sect2 id="zend.validate.set.string_length">
  196. <title>StringLength</title>
  197. <para>
  198. Returns <constant>TRUE</constant> if and only if the string length of <code>$value</code> is at
  199. least a minimum and no greater than a maximum (when the max option is not
  200. <constant>NULL</constant>). The <code>setMin()</code> method throws an exception if the minimum
  201. length is set to a value greater than the set maximum length, and the
  202. <code>setMax()</code> method throws an exception if the maximum length is set to a
  203. value less than than the set minimum length. This class supports UTF-8 and other
  204. character encodings, based on the current value of <ulink
  205. url="http://www.php.net/manual/en/ref.iconv.php#iconv.configuration"><code>iconv.internal_encoding</code></ulink>.
  206. If you need a different encoding you can set it with the accessor methods getEncoding
  207. and setEncoding.
  208. </para>
  209. </sect2>
  210. </sect1>
  211. <!--
  212. vim:se ts=4 sw=4 et:
  213. -->