Peter,

Thank you for the reply.

I'll open an issue then.


Martin Carpentier


On Sun, Sep 13, 2009 at 08:45, Peter Warnock <[email protected]> wrote:

> Based on your example, it looks like the backward compatibility was broken.
>
> - pw
>
>
> On Sat, Sep 12, 2009 at 7:20 AM, Martin Carpentier <
> [email protected]> wrote:
>
>> Hi,
>>
>> I made a previous 
>> post<http://www.nabble.com/Zend_Validate_NotEmpty-and-unchecked-radio-button-marked-as-required--fields-tt25278297.html>about
>>  this problem but never got any reply. I realize the title was probably
>> a bit unclear.
>> So here's my second attempt.
>>
>> Since ZF 1.9.x when you  try to validate a null value with
>> Zend_Validate_NotEmpty you get the INVALID error message instead of the
>> IS_EMPTY error message.
>>
>> If you try:
>>
>> $value     = null;
>> $validator = new Zend_Validate_NotEmpty();
>>
>> Zend_Debug::dump($validator->isValid($value));
>> Zend_Debug::dump($validator->getErrors());
>> Zend_Debug::dump($validator->getMessages());
>>
>> since ZF 1.9.x it results in:
>>
>> bool(false)
>>
>> array(1) {
>>  [0] => string(15) "notEmptyInvalid"
>> }
>>
>> array(1) {
>>  ["notEmptyInvalid"] => string(76) "Invalid type given, value should be
>> float, string, array, boolean or integer"
>> }
>>
>> before ZF 1.9.x it would result in:
>>
>> bool(false)
>>
>> array(1) {
>>  [0] => string(7) "isEmpty"
>> }
>>
>> array(1) {
>>  ["isEmpty"] => string(36) "Value is required and can't be empty"
>> }
>>
>>
>> I believe the expected behavior is to get the IS_EMPTY and not the INVALID
>> error type.
>>
>> A fix for this would be to check that the value is not null before
>> checking its type (in Zend/Validate/NotEmpty.php on line 56)
>>
>> if (null !== $value && !is_string($value) && !is_int($value) &&
>> !is_float($value) && !is_bool($value) &&
>>     !is_array($value)) {
>>     $this->_error(self::INVALID);
>>     return false;
>> }
>>
>> Could someone confirm this issue?
>>
>> Martin Carpentier
>>
>
>

Reply via email to