ZF-7843: Zend_Validate_NotEmpty and null values

Issue Type: Bug Created: 2009-09-14T01:48:20.000+0000 Last Updated: 2009-09-15T10:12:24.000+0000 Status: Resolved Fix version(s): - 1.9.3 (22/Sep/09)

Reporter: Martin Carpentier (hurkyl) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:


Since ZF 1.9.0 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:

<pre class="literal">
$value     = null;
$validator = new Zend_Validate_NotEmpty();


since ZF 1.9.0 it results in:

<pre class="literal">

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.0 it would result in:

<pre class="literal">

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)

<pre class="literal">
if (null !== $value && !is_string($value) && !is_int($value) && !is_float($value) && !is_bool($value) &&
    !is_array($value)) {
    return false;

This issue might be related to #ZF-7631


Posted by Thomas Weidner (thomas) on 2009-09-14T11:09:45.000+0000

No it's not dependend... Validating objects does not make sense as objects are ALWAYS filled and can not be empty.

Posted by Thomas Weidner (thomas) on 2009-09-14T11:11:30.000+0000

Tested with next mini release. Unable to reproduce. Probably already fixed in past.

Posted by Martin Carpentier (hurkyl) on 2009-09-15T02:31:37.000+0000

I just checked and you're right, it has been fixed in r18092

Right between when I posted the issue and last time I checked the repository.


Posted by Thomas Weidner (thomas) on 2009-09-15T10:12:20.000+0000

No problem... it's fixed, and that's all what counts ;-)

Have you found an issue?

See the Overview section for more details.


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

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