Zend_Validate-Migration.xml 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <!-- EN-Revision: 17908 -->
  4. <sect1 id="zend.validate.migration">
  5. <title>以前のバージョンからの移行</title>
  6. <para>
  7. <classname>Zend_Validate</classname>の<acronym>API</acronym>は、時折変わってきました。
  8. 以前のバージョンで<classname>Zend_Validate</classname>とそのサブコンポーネントを使い始めたなら、
  9. 新しい<acronym>API</acronym>を使うようスクリプトを移行するために、下記のガイドラインに従ってください。
  10. </para>
  11. <sect2 id="zend.validate.migration.fromoneninetooneten">
  12. <title>1.9から1.10以降への移行</title>
  13. <sect3 id="zend.validate.migration.fromoneninetooneten.selfwritten">
  14. <title>書かれたアダプタ自身</title>
  15. <para>
  16. かかれたバリデータ自身の内部からエラーを返すよう設定するときは、
  17. <methodname>_error()</methodname>メソッドを呼ばなくてはいけません。
  18. Zend Framework 1.10 以前では、パラメータを与えなくてもこのメソッドを呼び出せました。
  19. そこで、最初に見つかったメッセージテンプレートを使いました。
  20. </para>
  21. <para>
  22. この振る舞いには、一つ以上の異なるメッセージを返すバリデータを使うときに問題があります。
  23. また、既存のバリデータを拡張すると、予期しない結果を得ることもあります。
  24. このせいで、あなたが期待した通りではないメッセージにユーザーが遭遇することにもなりました。
  25. </para>
  26. <programlisting language="php"><![CDATA[
  27. My_Validator extends Zend_Validate_Abstract
  28. {
  29. public isValid($value)
  30. {
  31. ...
  32. $this->_error(); // 異なるOS間での予期されない結果
  33. ...
  34. }
  35. }
  36. ]]></programlisting>
  37. <para>
  38. この問題を防ぐために、<methodname>_error()</methodname>メソッドにパラメータを与えないで呼び出すことは、
  39. もはやできなくなります。
  40. </para>
  41. <programlisting language="php"><![CDATA[
  42. My_Validator extends Zend_Validate_Abstract
  43. {
  44. public isValid($value)
  45. {
  46. ...
  47. $this->_error(self::MY_ERROR); // 定義されたエラー、予期されない結果ではありません
  48. ...
  49. }
  50. }
  51. ]]></programlisting>
  52. </sect3>
  53. <sect3 id="zend.validate.migration.fromoneninetooneten.datevalidator">
  54. <!-- TODO: to be translated -->
  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>