Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File/Count validator does not work #24

Closed
weierophinney opened this issue Dec 31, 2019 · 5 comments · Fixed by #356
Closed

File/Count validator does not work #24

weierophinney opened this issue Dec 31, 2019 · 5 comments · Fixed by #356
Labels
Bug Something isn't working

Comments

@weierophinney
Copy link
Member

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

Originally posted by @autowp at zendframework/zend-validator#114

@weierophinney weierophinney added the Bug Something isn't working label Dec 31, 2019
@weierophinney
Copy link
Member Author

The documentation of the validator is also wrong.


Originally posted by @froschdesign at zendframework/zend-validator#114 (comment)

@weierophinney
Copy link
Member Author

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


Originally posted by @bfolliot at zendframework/zend-validator#114 (comment)

@cbichis
Copy link

cbichis commented Nov 26, 2020

Hi,

It's this fixed?

@froschdesign
Copy link
Member

@cbichis
Unfortunately not yet, but any help is welcome. Thanks in advance!

@gsteel
Copy link
Member

gsteel commented Jul 11, 2024

Closed via #356 - This patch drops support for legacy Laminas\File\Transfer api so it's no longer an issue, also, dirname is verifiably not called on non-strings.

@gsteel gsteel closed this as completed Jul 11, 2024
@gsteel gsteel linked a pull request Jul 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants