Zend_Validate-Set.xml 9.0 KB

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