Zend_Validate-Set.xml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. <xi:include href="Zend_Validate-Hex.xml" />
  98. <xi:include href="Zend_Validate-Hostname.xml" />
  99. <sect2 id="zend.validate.set.iban">
  100. <title>Iban</title>
  101. <para>
  102. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> contains a
  103. valid IBAN (International Bank Account Number). IBAN numbers are validated against the
  104. country where they are used and by a checksum.
  105. </para>
  106. <para>
  107. There are two ways to validate IBAN numbers. As first way you can give a locale which
  108. represents a country. Any given IBAN number will then be validated against this country.
  109. </para>
  110. <programlisting language="php"><![CDATA[
  111. $validator = new Zend_Validate_Iban('de_AT');
  112. $iban = 'AT611904300234573201';
  113. if ($validator->isValid($iban)) {
  114. // IBAN appears to be valid
  115. } else {
  116. // IBAN is invalid
  117. foreach ($validator->getMessages() as $message) {
  118. echo "$message\n";
  119. }
  120. }
  121. ]]></programlisting>
  122. <para>
  123. This should be done when you want to validate IBAN numbers for a single countries. The
  124. simpler way of validation is not to give a locale like shown in the next example.
  125. </para>
  126. <programlisting language="php"><![CDATA[
  127. $validator = new Zend_Validate_Iban();
  128. $iban = 'AT611904300234573201';
  129. if ($validator->isValid($iban)) {
  130. // IBAN appears to be valid
  131. } else {
  132. // IBAN is invalid
  133. }
  134. ]]></programlisting>
  135. <para>
  136. But this shows one big problem: When you have to accept only IBAN numbers from one
  137. single country, for example france, then IBAN numbers from other countries would also be
  138. valid. Therefor just remember: When you have to validate a IBAN number against a defined
  139. country you should give the locale. And when you accept all IBAN numbers regardless of
  140. any country omit the locale for simplicity.
  141. </para>
  142. </sect2>
  143. <xi:include href="Zend_Validate-Identical.xml" />
  144. <xi:include href="Zend_Validate-InArray.xml" />
  145. <sect2 id="zend.validate.set.int">
  146. <title>Int</title>
  147. <para>
  148. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is a valid
  149. integer. Since Zend Framework 1.8 this validator takes into account the actual locale
  150. from browser, environment or application wide set locale. You can of course use the
  151. get/setLocale accessors to change the used locale or give it while creating a instance
  152. of this validator.
  153. </para>
  154. </sect2>
  155. <xi:include href="Zend_Validate-Ip.xml" />
  156. <xi:include href="Zend_Validate-Isbn.xml" />
  157. <sect2 id="zend.validate.set.less_than">
  158. <title>LessThan</title>
  159. <para>
  160. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> is less than
  161. the maximum boundary.
  162. </para>
  163. </sect2>
  164. <xi:include href="Zend_Validate-NotEmpty.xml" />
  165. <xi:include href="Zend_Validate-PostCode.xml" />
  166. <sect2 id="zend.validate.set.regex">
  167. <title>Regex</title>
  168. <para>
  169. Returns <constant>TRUE</constant> if and only if <varname>$value</varname> matches
  170. against a regular expression pattern.
  171. </para>
  172. </sect2>
  173. <xi:include href="Zend_Validate-Sitemap.xml" />
  174. <sect2 id="zend.validate.set.string_length">
  175. <title>StringLength</title>
  176. <para>
  177. Returns <constant>TRUE</constant> if and only if the string length of
  178. <varname>$value</varname> is at least a minimum and no greater than a maximum (when the
  179. max option is not <constant>NULL</constant>). The <methodname>setMin()</methodname>
  180. method throws an exception if the minimum length is set to a value greater than the set
  181. maximum length, and the <methodname>setMax()</methodname> method throws an exception if
  182. the maximum length is set to a value less than the set minimum length. This class
  183. supports UTF-8 and other character encodings, based on the current value of <ulink
  184. url="http://www.php.net/manual/en/ref.iconv.php#iconv.configuration">iconv.internal_encoding</ulink>.
  185. If you need a different encoding you can set it with the accessor methods getEncoding
  186. and setEncoding.
  187. </para>
  188. </sect2>
  189. </sect1>
  190. <!--
  191. vim:se ts=4 sw=4 et:
  192. -->