This actually is a bug in Zend Framework thas has not been fixed as of yet. And as Zend_Filter_Input
has been discontinued with Zend Framework 2, I'll highly doubt that it will ever be. However, there is a patch attached to the ticket that should resolve this issue.
I also did a little debugging and could track it down to the method _validateRule
in Zend_Filter_Input:
There you can find this code block:
if (!is_array($field)) {
$field = array($field);
}
[...]
foreach ($field as $key => $value) {
[...]
if (!$validatorChain->isValid($value)) {
$field
contains the value of the field. As you can see, if you pass a non-array value, it is put into an array, so that the foreach block is entered. However, if you pass an empty array, then $field
will stay array(0) {}
and therefore the whole foreach
block will not be entered. Therefore not a single validation (nor a non-empty check) will be exectued.
I also tried to find a workaround, but they are all rather awkward. Therefore, the most simple workaround for this would be to check if $value
is an empty array.