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

Empty validation message for file input when sent array for file input #184

Closed
ruzann opened this issue Jul 15, 2019 · 3 comments
Closed
Labels
Milestone

Comments

@ruzann
Copy link
Contributor

ruzann commented Jul 15, 2019

Let's say I have an FileInput type input field.

..,
[
                'required' => false,
                'validators' => [
                    0 => [
                        'name' => \Zend\Validator\File\UploadFile::class,
                        'options' => [],
                    ],
                    1 => [
                        'name' => \Zend\Validator\File\Size::class,
                        'options' => [
                            'max ' => '1MB',
                        ],
                    ],
                    2 => [
                        'name' => \Zend\Validator\File\MimeType::class,
                        'options' => [
                            'mimeType' => 'image/jpg, image/jpeg, image/png, image/gif, image/bmp',
                        ],
                    ],
                    3 => [
                        'name' => \Zend\Validator\File\ImageSize::class,
                        'options' => [
                            'minWidth' => 50,
                            'minHeight' => 50,
                            'maxWidth' => 2048,
                            'maxHeight' => 2048,
                        ],
                    ],
                ],
                'filters' => [],
                'name' => 'logo',
                'description' => 'logo image file',
                'field_type' => 'file',
                'type' => \Zend\InputFilter\FileInput::class,
                'continue_if_empty' => true,
            ]

And I send

logo[] = 'test'

The response should be

{

"validation_messages": {
    "logo": {
        "fileUploadFileErrorNoFile": "No file was uploaded",
        "fileSizeNotFound": "File is not readable or does not exist",
        "fileMimeTypeNotReadable": "File is not readable or does not exist",
        "fileImageSizeNotReadable": "File is not readable or does not exist"
    }
},
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Unprocessable Entity",
"status": 422,
"detail": "Failed Validation"

}

But response is this.

{

"validation_messages": {
    "logo": []
},
"type": "http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html",
"title": "Unprocessable Entity",
"status": 422,
"detail": "Failed Validation"

}

@dennybrandes
Copy link

Hey, which version of zend-inputfilter are you using?

@ruzann
Copy link
Contributor Author

ruzann commented Jul 15, 2019

version is 2.10.0

@dennybrandes
Copy link

I saw that you use continue_if_empty option. I'm not sure, if this is related:
#26

@michalbundyra michalbundyra added this to the 2.10.1 milestone Aug 24, 2019
michalbundyra added a commit that referenced this issue Aug 28, 2019
Fixed "Empty validation message for file input when sent array for file input #184"
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

3 participants