Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

File/Count validator does not work #114

Open
autowp opened this issue Sep 14, 2016 · 3 comments
Open

File/Count validator does not work #114

autowp opened this issue Sep 14, 2016 · 3 comments
Labels

Comments

@autowp
Copy link

autowp commented Sep 14, 2016

Validation result always false. Warning dropped

Warning: dirname() expects parameter 1 to be string, array given in /home/autowp/autowp.ru/vendor/zendframework/zend-validator/src/File/Count.php on line 209

<form action="" method="post" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit" />
</form>
$form = new \Zend\Form\Form(null);
$form->add([
    'name' => 'file',
    'type' => 'File'
]);

$inputFilter = new \Zend\InputFilter\InputFilter();
$inputFilter->add([
    'validators' => [
        [
            'name'    => \Zend\Validator\File\Count::class,
            'options' => ['min' => 1]
        ]
    ]
], 'file');

$form->setInputFilter($inputFilter);

$form->setData($this->getRequest()->getFiles());
print $form->isValid() ? 'valid' : 'invalid'; // invalid, warning dropped
@froschdesign
Copy link
Member

froschdesign commented Jun 10, 2017

The documentation of the validator is also wrong.

@bfolliot
Copy link

bfolliot commented Oct 5, 2018

Same issue for me, the validator is call for each file in Zend\InputFilter\FileInput@isValid do not get the right parameters ("value" and "context" instead of "filenames" and "files")

Version of zendframework/zend-validator : 2.10.2

@weierophinney
Copy link
Member

This repository has been closed and moved to laminas/laminas-validator; a new issue has been opened at laminas/laminas-validator#24.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants