Issues

ZF-11267: Custom error message from Zend_Validate_NotEmpty not considered when using it along with Zend_Filter_Input

Description

Given the following code


        require_once 'Zend/Filter/Input.php';
        
        require_once 'Zend/Validate/NotEmpty.php';
        
        
        $notEmpty = new Zend_Validate_NotEmpty();
        $notEmpty->setMessage("\"key\" may not be empty", Zend_Validate_NotEmpty::IS_EMPTY);
        
        $filter = New Zend_Filter_Input(array(), array(
            'key' => array($notEmpty)
        ), array('key' => ""));
    
        var_dump($filter->getInvalid());

I expect the following result:


array
  'key' => 
    array
      'isEmpty' => string 'You must give a non-empty value for field 'key''

However, I'm getting the following result


array
  'key' => 
    array
      'isEmpty' => string '"key" may not be empty'

which means that there is no way to actually use the NotEmpty Validator along with a custom error message, since some funny Zend_Filter_Input implementation preceeds my validator configuration.

Comments

uhm... what's wrong with the {{monospace}} wiki syntax?

nvm

Today I created a unit test that proves this error exists. I had previously discovered the error in a more informal way. The bad news is, that other validators are equally affected by this issue, not just the 'NotEmpty' validator.

I will try to fix this.

Added patches that resolve the issue.

I will leave the patches here for a few days for community review.

I will also assign it to Thomas hoping that he will find the time to evaluate them before I commit them.

Changed to patch and assigned to Thomas.

Looks good on the first hand. Thanks for the fix. Please add the patch to ZF1 and keep the issue opened for integration into ZF2.

fix is in svn now

reopened for integration into ZF2

Added to ZF2 with GH-274 Changed assignee to Bart because it was his patch