59.6. Migrating from previous versions

The API of Zend_Validate has changed from time to time. If you started to use Zend_Validate and its subcomponents in earlier versions follow the guidelines below to migrate your scripts to use the new API.

59.6.1. Migrating from 1.9 to 1.10 or newer

59.6.1.1. Self written adapters

When setting returning a error from within a self written validator you have to call the _error() 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.

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.

My_Validator extends Zend_Validate_Abstract
{
    public isValid($value)
    {
        ...
        $this->_error(); // unexpected results between different OS
        ...
    }
}

To prevent this problem the _error() method is no longer allowed to be called without giving a parameter.

My_Validator extends Zend_Validate_Abstract
{
    public isValid($value)
    {
        ...
        $this->_error(self::MY_ERROR); // defined error, no unexpected results
        ...
    }
}