Zend Framework

Zend_Filter_Input disregards field 'messages' meta-command

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: Next Major Release
  • Fix Version/s: 1.9.3
  • Component/s: Zend_Filter_Input
  • Labels:
    None

Description

Zend_Filter_Input disregards custom error messages passed to it via the 'messages' meta-command. This has been working previously but has been broken since the 1.8 ver. release.

For example, the following validators array:

$validators = array(
'name' => array('NotEmpty','messages' => 'Please enter your name'),
'subject' => array('NotEmpty','messages' => 'Please enter a subject'),
'email' => array('EmailAddress','messages' => 'Please enter a valid Email address'),
'content' => array('NotEmpty','messages' => 'Please enter message contents')
);

Returns the following message stack:

array(5) {
["name"] => array(1) { ["isEmpty"] => string(48) "You must give a non-empty value for field 'name'" }
["subject"] => array(1) { ["isEmpty"] => string(51) "You must give a non-empty value for field 'subject'" }
["content"] => array(1) { ["isEmpty"] => string(51) "You must give a non-empty value for field 'content'" }
["email"] => array(1) { [0] => string(24) "You must give a non-empty value for field 'content''" }
}

Activity

Hide
Oleg Luchenko added a comment -

I confirmed this bug. I have same problem with default error messages. In v.1.7.8 all work's fine.

Show
Oleg Luchenko added a comment - I confirmed this bug. I have same problem with default error messages. In v.1.7.8 all work's fine.
Hide
Julien Ricard added a comment -

This bug occurs only with the "NotEmpty" validator. Other seem to work fine.

Show
Julien Ricard added a comment - This bug occurs only with the "NotEmpty" validator. Other seem to work fine.
Hide
David Mintz added a comment -

@Julien: that's not quite my experience. Consider:

$validators = array(
'email' => array(
'NotEmpty',
'EmailAddress',
new Zend_Validate_Regex('/.+nys[dp]\.uscourts\.gov$/i'),
'messages'=>array(
'Email is required',
'Email address is malformed',
'Email domain must be either nysd.uscourts.gov or nysp.uscourts.gov'),
'breakChainOnFailure'=>true,

),

);
$input = new Zend_Filter_Input(null,$validators,
array(
'email'=>'barf'
)
);

if (! $input->isValid()) {
print_r($input->getMessages());
}

outputs the default error message instead of the one I (try to) pass in:

(
[email] => Array
(
[emailAddressInvalidFormat] => 'barf' is not a valid email address in the basic format local-part@hostname
)

)

Show
David Mintz added a comment - @Julien: that's not quite my experience. Consider: $validators = array( 'email' => array( 'NotEmpty', 'EmailAddress', new Zend_Validate_Regex('/.+nys[dp]\.uscourts\.gov$/i'), 'messages'=>array( 'Email is required', 'Email address is malformed', 'Email domain must be either nysd.uscourts.gov or nysp.uscourts.gov'), 'breakChainOnFailure'=>true, ), ); $input = new Zend_Filter_Input(null,$validators, array( 'email'=>'barf' ) ); if (! $input->isValid()) { print_r($input->getMessages()); } outputs the default error message instead of the one I (try to) pass in: ( [email] => Array ( [emailAddressInvalidFormat] => 'barf' is not a valid email address in the basic format local-part@hostname ) )
Hide
Thomas Weidner added a comment -

@David:
You don't use the same notation as Eran...
Your problem is different than Eran's.

Show
Thomas Weidner added a comment - @David: You don't use the same notation as Eran... Your problem is different than Eran's.
Hide
David Mintz added a comment -

I don't quite understand why it would matter. It looks like my general problem is "it doesn't work," i.e., can't get Zend_Filter_Input to let me override the default error messages when there's more than one rule on a field. In any case, is my issue something already in the tracker or should I file one? And... do you know if there are any plans to address this issue and/or mine?

Show
David Mintz added a comment - I don't quite understand why it would matter. It looks like my general problem is "it doesn't work," i.e., can't get Zend_Filter_Input to let me override the default error messages when there's more than one rule on a field. In any case, is my issue something already in the tracker or should I file one? And... do you know if there are any plans to address this issue and/or mine?
Hide
Thomas Weidner added a comment -

*) When something is different coded than also the issue is different
*) That it does not work is not true... using another notation there is no problem at all
*) There is already another issue for your notation... a simple search would have shown you this
*) As you have seen I took over this issue 6 days ago
*) I can not solve 80 issues at the same time so please be patient as already mentioned several times... one after the oher will be solved

Show
Thomas Weidner added a comment - *) When something is different coded than also the issue is different *) That it does not work is not true... using another notation there is no problem at all *) There is already another issue for your notation... a simple search would have shown you this *) As you have seen I took over this issue 6 days ago *) I can not solve 80 issues at the same time so please be patient as already mentioned several times... one after the oher will be solved
Hide
David Mintz added a comment - - edited

*) Reasonable minds may disagree, but I would respectfully submit that when code that conforms to the documented API runs faultlessly in one version of the ZF but generates undesired output in a subsequent version, it can fairly be said that something "doesn't work," and
*) I searched in good faith for the issue, with negative results, perhaps because
*) your understanding of the issues greatly exceeds my own, which is why you're a contributor and I, a mere consumer, who
*) failed to notice you took on the issue so recently, and who, in any event, suggests that you
*) please relax and accept my sincere gratitude for your exertions.

Show
David Mintz added a comment - - edited *) Reasonable minds may disagree, but I would respectfully submit that when code that conforms to the documented API runs faultlessly in one version of the ZF but generates undesired output in a subsequent version, it can fairly be said that something "doesn't work," and *) I searched in good faith for the issue, with negative results, perhaps because *) your understanding of the issues greatly exceeds my own, which is why you're a contributor and I, a mere consumer, who *) failed to notice you took on the issue so recently, and who, in any event, suggests that you *) please relax and accept my sincere gratitude for your exertions.
Hide
Thomas Weidner added a comment -

@David: LOL

Let's say: I will solve them soon, ok ?

Your issue is related to ZF-7034 (using one element with multiple validators and messages). Internally I have fixed it already so there is a solution for it soon.

This issue (using multiple elements with one validator and message) could be fixed but I can only verify when I've finished the other one.

When all is ok, then there is a solution within one day. Does this sound good to you ?

Show
Thomas Weidner added a comment - @David: LOL Let's say: I will solve them soon, ok ? Your issue is related to ZF-7034 (using one element with multiple validators and messages). Internally I have fixed it already so there is a solution for it soon. This issue (using multiple elements with one validator and message) could be fixed but I can only verify when I've finished the other one. When all is ok, then there is a solution within one day. Does this sound good to you ?
Hide
Thomas Weidner added a comment -

Fixed with r17845.

And sorry that I was wrong... not one day but only some hours

Show
Thomas Weidner added a comment - Fixed with r17845. And sorry that I was wrong... not one day but only some hours

People

Vote (3)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: