| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect1 id="zend.validate.migration">
- <title>Migrating from previous versions</title>
- <para>
- The <acronym>API</acronym> of <classname>Zend_Validate</classname> has changed from time
- to time. If you started to use <classname>Zend_Validate</classname> and its subcomponents
- in earlier versions follow the guidelines below to migrate your scripts to
- use the new <acronym>API</acronym>.
- </para>
- <sect2 id="zend.validate.migration.fromoneninetooneten">
- <title>Migrating from 1.9 to 1.10 or newer</title>
- <sect3 id="zend.validate.migration.fromoneninetooneten.selfwritten">
- <title>Self written adapters</title>
- <para>
- When setting returning a error from within a self written validator you have to
- call the <methodname>_error()</methodname> method. Before Zend Framework 1.10 you
- were able to call this method without giving a parameter. It used then the first
- found message template.
- </para>
- <para>
- This behaviour is problematic when you have validators with more than one different
- message to be returned. Also when you extend an existing validator you can get
- unexpected results. This could lead to the problem that your user get not the
- message you expected.
- </para>
- <programlisting language="php"><![CDATA[
- My_Validator extends Zend_Validate_Abstract
- {
- public isValid($value)
- {
- ...
- $this->_error(); // unexpected results between different OS
- ...
- }
- }
- ]]></programlisting>
- <para>
- To prevent this problem the <methodname>_error()</methodname> method is no longer
- allowed to be called without giving a parameter.
- </para>
- <programlisting language="php"><![CDATA[
- My_Validator extends Zend_Validate_Abstract
- {
- public isValid($value)
- {
- ...
- $this->_error(self::MY_ERROR); // defined error, no unexpected results
- ...
- }
- }
- ]]></programlisting>
- </sect3>
- <sect3 id="zend.validate.migration.fromoneninetooneten.datevalidator">
- <title>Simplification in date validator</title>
- <para>
- Before Zend Framework 1.10 2 identical messages were thrown within the date
- validator. These were <constant>NOT_YYYY_MM_DD</constant> and
- <constant>FALSEFORMAT</constant>. As of Zend Framework 1.10 only the
- <constant>FALSEFORMAT</constant> message will be returned when the given date
- does not match the set format.
- </para>
- </sect3>
- <sect3 id="zend.validate.migration.fromoneninetooneten.barcodevalidator">
- <title>Fixes in Alpha, Alnum and Barcode validator</title>
- <para>
- Before Zend Framework 1.10 the messages within the 2 barcode adapters, the Alpha
- and the Alnum validator were identical. This introduced problems when using custom
- messages, translations or multiple instances of these validators.
- </para>
- <para>
- As with Zend Framework 1.10 the values of the constants were changed to
- be unique. When you used the constants as proposed in the manual there is
- no change for you. But when you used the content of the constants in your code
- then you will have to change them. The following table shows you the changed values:
- </para>
- <table id="zend.validate.migration.fromoneninetooneten.barcodevalidator.table">
- <title>Available Validation Messages</title>
- <tgroup cols="3">
- <thead>
- <row>
- <entry>Validator</entry>
- <entry>Constant</entry>
- <entry>Value</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry>Alnum</entry>
- <entry><constant>STRING_EMPTY</constant></entry>
- <entry>alnumStringEmpty</entry>
- </row>
- <row>
- <entry>Alpha</entry>
- <entry><constant>STRING_EMPTY</constant></entry>
- <entry>alphaStringEmpty</entry>
- </row>
- <row>
- <entry>Barcode_Ean13</entry>
- <entry><constant>INVALID</constant></entry>
- <entry>ean13Invalid</entry>
- </row>
- <row>
- <entry>Barcode_Ean13</entry>
- <entry><constant>INVALID_LENGTH</constant></entry>
- <entry>ean13InvalidLength</entry>
- </row>
- <row>
- <entry>Barcode_UpcA</entry>
- <entry><constant>INVALID</constant></entry>
- <entry>upcaInvalid</entry>
- </row>
- <row>
- <entry>Barcode_UpcA</entry>
- <entry><constant>INVALID_LENGTH</constant></entry>
- <entry>upcaInvalidLength</entry>
- </row>
- <row>
- <entry>Digits</entry>
- <entry><constant>STRING_EMPTY</constant></entry>
- <entry>digitsStringEmpty</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </sect3>
- </sect2>
- </sect1>
|