Zend_Validate-Alnum.xml 3.6 KB

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