Zend_Validate-Set.xml 9.8 KB

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