ZF-9968: NotEmpty Validator treats objects as empty

Issue Type: Bug Created: 2010-06-09T05:49:55.000+0000 Last Updated: 2010-07-24T11:15:36.000+0000 Status: Resolved Fix version(s): - 1.10.7 (28/Jul/10)

Reporter: Thomas Baumann (t11n) Assignee: Thomas Weidner (thomas) Tags: - Zend_Validate

Related issues: Attachments:


I am referring to issue ZF-7631. There is claimed that Zend_Validate_NotEmpty does not accept anything other than string, boolean etc.

Although I basically agree with Thomas' post, that it does not make sense to check an object for emptiness, I wonder why it treats objects as empty by default rather than as "notEmpty". I came over that issue when trying to validate a Zend_Date object with the input filter. The property's presence is required, which makes Zend_Filter_Input add an NotEmpty-Validator to the chain. As all objects are always treated as empty, my date object does never get the chance to meet Zend_Validate_Date.

So please consider to change the default behaviour to "notEmpty" for objects instead of "empty". If null is passed instead of the object, it then should hit "empty", as expected. This issue impacts the filter chains of zend_filter_input.

Thanks for looking into the matter again.


Posted by Thomas Weidner (thomas) on 2010-06-09T12:43:44.000+0000

Zend_Validate_NotEmpty returns an failure and states: "Invalid type given, value should be float, string, array, boolean or integer"

The same would apply to resources, connections or other non-scalar inputs.

The thing is: When you give a false input, you can't rely on a correct functional behaviour of a validator. False means "failure"... which type of failure has to be checked.

When we switch the behaviour of the validator to return "true" for all types which are not recognised it would also be treated as false behaviour.

Posted by Thomas Weidner (thomas) on 2010-07-24T11:15:35.000+0000

New feature implemented with r22663

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.