Zend_Validate-Alnum.xml 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.validate.set.alnum">
  4. <title>Alnum</title>
  5. <para>
  6. <classname>Zend_Validate_Alnum</classname> allows you to validate if a given value contains
  7. only alphabetical characters and digits. There is no length limitation for the input
  8. you want to validate.
  9. </para>
  10. <sect3 id="zend.validate.set.alnum.options">
  11. <title>Supported options for Zend_Validate_Alnum</title>
  12. <para>
  13. The following options are supported for <classname>Zend_Validate_Alnum</classname>:
  14. </para>
  15. <itemizedlist>
  16. <listitem>
  17. <para>
  18. <emphasis><property>allowWhiteSpace</property></emphasis>: If whitespace
  19. characters are allowed. This option defaults to <constant>FALSE</constant>
  20. </para>
  21. </listitem>
  22. </sect3>
  23. <sect3 id="zend.validate.set.alnum.basic">
  24. <title>Basic usage</title>
  25. <para>
  26. A basic example is the following one:
  27. </para>
  28. <programlisting language="php"><![CDATA[
  29. $validator = new Zend_Validate_Alnum();
  30. if ($validator->isValid('Abcd12')) {
  31. // value contains only allowed chars
  32. } else {
  33. // false
  34. }
  35. ]]></programlisting>
  36. </sect3>
  37. <sect3 id="zend.validate.set.alnum.whitespace">
  38. <title>Using whitespaces</title>
  39. <para>
  40. Per default whitespaces are not accepted because they are not part of the alphabet.
  41. Still, there is a way to accept them as input. This allows to validate complete
  42. sentences or phrases.
  43. </para>
  44. <para>
  45. To allow the usage of whitespaces you need to give the
  46. <property>allowWhiteSpace</property> option. This can be done while creating an instance
  47. of the validator, or afterwards by using <methodname>setAllowWhiteSpace()</methodname>.
  48. To get the actual state you can use <methodname>getAllowWhiteSpace()</methodname>.
  49. </para>
  50. <programlisting language="php"><![CDATA[
  51. $validator = new Zend_Validate_Alnum(array('allowWhiteSpace' => true));
  52. if ($validator->isValid('Abcd and 12')) {
  53. // value contains only allowed chars
  54. } else {
  55. // false
  56. }
  57. ]]></programlisting>
  58. </sect3>
  59. <sect3 id="zend.validate.set.alnum.languages">
  60. <title>Using different languages</title>
  61. <para>
  62. When using <classname>Zend_Validate_Alnum</classname> then the language which the user
  63. sets within his browser will be used to set the allowed characters. This means when your
  64. user sets <emphasis>de</emphasis> for german then he can also enter characters like
  65. <emphasis>ä</emphasis>, <emphasis>ö</emphasis> and <emphasis>ü</emphasis> additionally
  66. to the characters from the english alphabet.
  67. </para>
  68. <para>
  69. Which characters are allowed depends completly on the used language as every language
  70. defines it's own set of characters.
  71. </para>
  72. <para>
  73. There are actually 3 languages which are not accepted in their own script. These
  74. languages are <emphasis>korean</emphasis>, <emphasis>japanese</emphasis> and
  75. <emphasis>chinese</emphasis> because this languages are using an alphabet where a
  76. single character is build by using multiple characters.
  77. </para>
  78. <para>
  79. In the case you are using these languages, the input will only be validated by using
  80. the english alphabet.
  81. </para>
  82. </sect3>
  83. </sect2>
  84. <!--
  85. vim:se ts=4 sw=4 et:
  86. -->