zendframework / zend-validator

Validator component from Zend Framework
BSD 3-Clause "New" or "Revised" License
181 stars 136 forks source link

PSR-7 file validation implemented #251

Closed icetee closed 5 years ago

icetee commented 5 years ago

This commit allows validation files with $request->getUploadedFiles().

But I got stuck in testing. I want to be able to use a $upload->getStream()->getMetadata('uri') and return example /tmp/abcd.

$stream = $this->prophesize(StreamInterface::class);
$upload = $this->prophesize(UploadedFileInterface::class);

$stream->getMetadata('uri')->willReturn($testFile);

$upload->getClientFilename()->willReturn('csgo.mo');
$upload->getClientMediaType()->willReturn('mo');
$upload->getError()->willReturn(0);
$upload->getStream()->willReturn($stream->reveal());
$upload->reveal();

$upload->getStream()->getMetadata('uri'); // Call to undefined method Prophecy\Prophecy\MethodProphecy::getMetadata()   
weierophinney commented 5 years ago

@icetee we already have support for validating PSR-7 uploaded files as of version 2.11.0; the support is even documented.

froschdesign commented 5 years ago

@weierophinney But this support will not work for (file) validators like Size, MimeType and so on.

froschdesign commented 5 years ago

Related to https://github.com/zendframework/zend-form/issues/227

icetee commented 5 years ago

I pushed the changes.

@weierophinney I have http-message package composer show -i | grep http-message.

icetee commented 5 years ago

Maybe related build failed - https://github.com/zendframework/zend-validator/issues/257

weierophinney commented 5 years ago

@icetee Yes, and I just pushed a fix for that to develop. :smile: