It appears I was using an older version of ZF (1.9.1, specifically). This
issue was apparently fixed in v1.9.3 (<
http://framework.zend.com/issues/browse/ZF-7034>). Silly me.


On Tue, Dec 1, 2009 at 11:14 AM, Ryan Lange <cl1mh422...@gmail.com> wrote:

> It looks like Zend_Filter_Input, for some reason, automatically runs a
> NotEmpty validator on every field. The message you're seeing is
> Zend_Filter_Input's NOT_EMPTY_MESSAGE.
>
> Setting the ALLOW_EMPTY meta command will get rid of it, but, of course,
> won't run your own NotEmpty validator.
>
> I haven't figured out a way to override this, though. And customizing
> NOT_EMPTY_MESSAGE is out of the question, because I want per-field messages
> (that don't reference the field name).
>
> Does anyone have a solution?
>
>
>
> On Thu, Aug 20, 2009 at 10:59 AM, David Mintz <da...@davidmintz.org>wrote:
>
>> I could use some help figuring out how to override the default validation
>> error messages with my own. Consider this snippet, based on the example in
>> the docs:
>>
>>
>> $validators = array(
>>     'month' => array(
>>         'NotEmpty',
>>         'Digits',
>>         'messages' => array(
>>                 0 =>'my custom message: this is empty',
>>                 1=>'my custom message: this ain\'t digits!'),
>>     )
>> );
>> $input = new Zend_Filter_Input(null,$validators,
>>     array(
>>         'month'=>''
>>     )
>> );
>> if ($input->isValid()) {
>>     echo "input is valid\n" ;
>> } else {
>>     print_r($input->getMessages());
>> }
>>
>>
>> Output when I run this in 1.7.8:
>>
>> Array
>> (
>>     [month] => Array
>>         (
>>             [isEmpty] => my custom message: this is empty yo
>>             [stringEmpty] => '' is an empty string
>>         )
>>
>> )
>>
>> Output when I run this in 1.9.0: (undesired):
>>
>>
>> Array
>> (
>>     [month] => Array
>>         (
>>             [isEmpty] => You must give a non-empty value for field 'month'
>>         )
>>
>> )
>>
>> I am having this problem with several Zend validation classes, not just
>> Zend_Validate_NotEmpty. Any help is much appreciated.
>>
>> --
>> David Mintz
>> http://davidmintz.org/
>>
>> The subtle source is clear and bright
>> The tributary streams flow through the darkness
>>
>
>

Reply via email to