Zend_Validate-Migration.xml 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.validate.migration">
  4. <title>Migrating from previous versions</title>
  5. <para>
  6. The <acronym>API</acronym> of <classname>Zend_Validate</classname> has changed from time
  7. to time. If you started to use <classname>Zend_Validate</classname> and its subcomponents
  8. in earlier versions follow the guidelines below to migrate your scripts to
  9. use the new <acronym>API</acronym>.
  10. </para>
  11. <sect2 id="zend.validate.migration.fromoneninetooneten">
  12. <title>Migrating from 1.9 to 1.10 or newer</title>
  13. <sect3 id="zend.validate.migration.fromoneninetooneten.selfwritten">
  14. <title>Self written adapters</title>
  15. <para>
  16. When setting returning a error from within a self written validator you have to
  17. call the <methodname>_error()</methodname> method. Before Zend Framework 1.10 you
  18. were able to call this method without giving a parameter. It used then the first
  19. found message template.
  20. </para>
  21. <para>
  22. This behaviour is problematic when you have validators with more than one different
  23. message to be returned. Also when you extend an existing validator you can get
  24. unexpected results. This could lead to the problem that your user get not the
  25. message you expected.
  26. </para>
  27. <programlisting language="php"><![CDATA[
  28. My_Validator extends Zend_Validate_Abstract
  29. {
  30. public isValid($value)
  31. {
  32. ...
  33. $this->_error(); // unexpected results between different OS
  34. ...
  35. }
  36. }
  37. ]]></programlisting>
  38. <para>
  39. To prevent this problem the <methodname>_error()</methodname> method is no longer
  40. allowed to be called without giving a parameter.
  41. </para>
  42. <programlisting language="php"><![CDATA[
  43. My_Validator extends Zend_Validate_Abstract
  44. {
  45. public isValid($value)
  46. {
  47. ...
  48. $this->_error(self::MY_ERROR); // defined error, no unexpected results
  49. ...
  50. }
  51. }
  52. ]]></programlisting>
  53. </sect3>
  54. <sect3 id="zend.validate.migration.fromoneninetooneten.datevalidator">
  55. <title>Simplification in date validator</title>
  56. <para>
  57. Before Zend Framework 1.10 2 identical messages were thrown within the date
  58. validator. These were <constant>NOT_YYYY_MM_DD</constant> and
  59. <constant>FALSEFORMAT</constant>. As of Zend Framework 1.10 only the
  60. <constant>FALSEFORMAT</constant> message will be returned when the given date
  61. does not match the set format.
  62. </para>
  63. </sect3>
  64. <sect3 id="zend.validate.migration.fromoneninetooneten.barcodevalidator">
  65. <title>Fixes in Alpha, Alnum and Barcode validator</title>
  66. <para>
  67. Before Zend Framework 1.10 the messages within the 2 barcode adapters, the Alpha
  68. and the Alnum validator were identical. This introduced problems when using custom
  69. messages, translations or multiple instances of these validators.
  70. </para>
  71. <para>
  72. As with Zend Framework 1.10 the values of the constants were changed to
  73. be unique. When you used the constants as proposed in the manual there is
  74. no change for you. But when you used the content of the constants in your code
  75. then you will have to change them. The following table shows you the changed values:
  76. </para>
  77. <table id="zend.validate.migration.fromoneninetooneten.barcodevalidator.table">
  78. <title>Available Validation Messages</title>
  79. <tgroup cols="3">
  80. <thead>
  81. <row>
  82. <entry>Validator</entry>
  83. <entry>Constant</entry>
  84. <entry>Value</entry>
  85. </row>
  86. </thead>
  87. <tbody>
  88. <row>
  89. <entry>Alnum</entry>
  90. <entry><constant>STRING_EMPTY</constant></entry>
  91. <entry>alnumStringEmpty</entry>
  92. </row>
  93. <row>
  94. <entry>Alpha</entry>
  95. <entry><constant>STRING_EMPTY</constant></entry>
  96. <entry>alphaStringEmpty</entry>
  97. </row>
  98. <row>
  99. <entry>Barcode_Ean13</entry>
  100. <entry><constant>INVALID</constant></entry>
  101. <entry>ean13Invalid</entry>
  102. </row>
  103. <row>
  104. <entry>Barcode_Ean13</entry>
  105. <entry><constant>INVALID_LENGTH</constant></entry>
  106. <entry>ean13InvalidLength</entry>
  107. </row>
  108. <row>
  109. <entry>Barcode_UpcA</entry>
  110. <entry><constant>INVALID</constant></entry>
  111. <entry>upcaInvalid</entry>
  112. </row>
  113. <row>
  114. <entry>Barcode_UpcA</entry>
  115. <entry><constant>INVALID_LENGTH</constant></entry>
  116. <entry>upcaInvalidLength</entry>
  117. </row>
  118. <row>
  119. <entry>Digits</entry>
  120. <entry><constant>STRING_EMPTY</constant></entry>
  121. <entry>digitsStringEmpty</entry>
  122. </row>
  123. </tbody>
  124. </tgroup>
  125. </table>
  126. </sect3>
  127. </sect2>
  128. </sect1>