ZF-5764: Zend_Form should note that '0' value is valid since 1.7 even with required=>true and notEmpty validator


Since 1.7 (I think) when creating form element and setting value 0 it will pass the notEmpty and required=>true validator. 0 is now considered valid value. Now one should enter empty string instead. I am not 100% if this is all 1.7 issue but on 1.6.2 '0' was not valid with above validators.


I also found this to be confusing ... I think the main issue here is what do NotEmtpy and Required mean in regards to a form value?

According to the PHP manual the function empty, considers the value 0 as empty; 0.0 is also considered empty although it's not stated in the manual.

In a form, the value 0 or 0.0 could be considered a value, which is the way the validation works at the moment and seems to make sense in regards to a form value.

I agree with Julian, the manual should state that the NotEmpty and Required validators consider the value 0 as a valid value and NotEmpty should not be confused with the PHP function empty().

Along this same topic, I also found it confusing when using the NotEmpty validator with a Zend_Form_Element. The documentation at 59.2.20. states that NotEmpty Returns TRUE if and only if $value is not an empty value. Yet the default value for the Zend_Form_Element _allowEmpty is true, which cancels out the NotEmpty validator. One could setAllowEmtpy to false along with setting the NotEmpty validator for the field, but it seems that it would make more sense to just use setRequired(true).

Added with r19353