Zend_Validate-Migration.xml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. </sect2>
  55. </sect1>