Zend_Validate-Iban.xml 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect2 id="zend.validate.set.iban">
  4. <title>Iban</title>
  5. <para>
  6. <classname>Zend_Validate_Iban</classname> validates if a given value could be a
  7. <acronym>IBAN</acronym> number. <acronym>IBAN</acronym> is the abbreviation for
  8. "International Bank Account Number".
  9. </para>
  10. <sect3 id="zend.validate.set.iban.options">
  11. <title>Supported options for Zend_Validate_Iban</title>
  12. <para>
  13. The following options are supported for <classname>Zend_Validate_Iban</classname>:
  14. </para>
  15. <itemizedlist>
  16. <listitem>
  17. <para>
  18. <emphasis><property>locale</property></emphasis>: Sets the locale which is used
  19. to get the <acronym>IBAN</acronym> format for validation.
  20. </para>
  21. </listitem>
  22. </itemizedlist>
  23. </sect3>
  24. <sect3 id="zend.validate.set.iban.basic">
  25. <title>IBAN validation</title>
  26. <para>
  27. <acronym>IBAN</acronym> numbers are always related to a country. This means that
  28. different countries use different formats for their <acronym>IBAN</acronym> numbers.
  29. This is the reason why <acronym>IBAN</acronym> numbers always need a locale. By knowing
  30. this we already know how to use <classname>Zend_Validate_Iban</classname>.
  31. </para>
  32. <sect4 id="zend.validate.set.iban.basic.application">
  33. <title>Application wide locale</title>
  34. <para>
  35. We could use the application wide locale. This means that when no option is given at
  36. initiation, <classname>Zend_Validate_Iban</classname> searches for the application
  37. wide locale. See the following code snippet:
  38. </para>
  39. <programlisting language="php"><![CDATA[
  40. // within bootstrap
  41. Zend_Registry::set('Zend_Locale', new Zend_Locale('de_AT'));
  42. // within the module
  43. $validator = new Zend_Validate_Iban();
  44. if ($validator->isValid('AT611904300234573201')) {
  45. // IBAN appears to be valid
  46. } else {
  47. // IBAN is not valid
  48. }
  49. ]]></programlisting>
  50. <note>
  51. <title>Application wide locale</title>
  52. <para>
  53. Of course this works only when an application wide locale was set within the
  54. registry previously. Otherwise <classname>Zend_Locale</classname> will try to
  55. use the locale which the client sends or, when non has been send, it uses the
  56. environment locale. Be aware that this can lead to unwanted behaviour within
  57. the validation.
  58. </para>
  59. </note>
  60. </sect4>
  61. <sect4 id="zend.validate.set.iban.basic.false">
  62. <title>Ungreedy IBAN validation</title>
  63. <para>
  64. Sometime it is usefull, just to validate if the given value <emphasis>is</emphasis>
  65. a <acronym>IBAN</acronym> number or not. This means that you don't want to validate
  66. it against a defined country. This can be done by using a
  67. <constant>FALSE</constant> as locale.
  68. </para>
  69. <programlisting language="php"><![CDATA[
  70. $validator = new Zend_Validate_Iban(array('locale' => false));
  71. // Note: you can also set a FALSE as single parameter
  72. if ($validator->isValid('AT611904300234573201')) {
  73. // IBAN appears to be valid
  74. } else {
  75. // IBAN is not valid
  76. }
  77. ]]></programlisting>
  78. <para>
  79. So <emphasis>any</emphasis> <acronym>IBAN</acronym> number will be valid. Note that
  80. this should not be done when you accept only accounts from a single country.
  81. </para>
  82. </sect4>
  83. <sect4 id="zend.validate.set.iban.basic.aware">
  84. <title>Region aware IBAN validation</title>
  85. <para>
  86. To validate against a defined country, you just need to give the wished locale.
  87. You can do this by the option <property>locale</property> and also afterwards by
  88. using <methodname>setLocale()</methodname>.
  89. </para>
  90. <programlisting language="php"><![CDATA[
  91. $validator = new Zend_Validate_Iban(array('locale' => 'de_AT'));
  92. if ($validator->isValid('AT611904300234573201')) {
  93. // IBAN appears to be valid
  94. } else {
  95. // IBAN is not valid
  96. }
  97. ]]></programlisting>
  98. <note>
  99. <title>Use full qualified locales</title>
  100. <para>
  101. You must give a full qualified locale, otherwise the country could not be
  102. detected correct because languages are spoken in multiple countries.
  103. </para>
  104. </note>
  105. </sect4>
  106. </sect3>
  107. </sect2>
  108. <!--
  109. vim:se ts=4 sw=4 et:
  110. -->