Zend_Validate-Set.xml 7.7 KB

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