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

Issue Type: Patch Created: 2011-04-06T14:07:32.000+0000 Last Updated: 2011-08-25T19:30:40.000+0000 Status: Resolved Fix version(s): - 1.11.11 (29/Sep/11)

  • Next Major Release ()

Reporter: Thorsten Suckow-Homberg (thorsten_suckow_homberg) Assignee: Bart McLeod ( Tags: - Zend_Filter_Input

  • Zend_Validate
  • validating

Related issues: Attachments: - Input.php.patch4


Given the following code

<pre class="highlight">
        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' => ""));

I expect the following result:

<pre class="highlight">
  'key' => 
      'isEmpty' => string 'You must give a non-empty value for field 'key''

However, I'm getting the following result

<pre class="highlight">
  'key' => 
      '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.


Posted by Thorsten Suckow-Homberg (thorsten_suckow_homberg) on 2011-04-06T14:08:25.000+0000

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

Posted by Thorsten Suckow-Homberg (thorsten_suckow_homberg) on 2011-04-06T14:12:36.000+0000


Posted by Bart McLeod ( on 2011-04-13T11:51:43.000+0000

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.

Posted by Bart McLeod ( on 2011-04-14T20:45:04.000+0000

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.

Posted by Bart McLeod ( on 2011-04-14T20:46:19.000+0000

Changed to patch and assigned to Thomas.

Posted by Thomas Weidner (thomas) on 2011-04-16T20:59:46.000+0000

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.

Posted by Bart McLeod ( on 2011-04-18T07:15:29.000+0000

fix is in svn now

Posted by Bart McLeod ( on 2011-04-18T16:33:15.000+0000

reopened for integration into ZF2

Posted by Thomas Weidner (thomas) on 2011-08-25T19:28:30.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.