Welcome Guest, Not a member yet? Register   Sign In
mime_in throws error when file is not passed

I have this code:

PHP Code:
  $validationRules = [
            'name'          => 'required',
            'subject'       => 'required',
            'email'         => 'required',
            'message'       => 'required',
            'sede'          => 'required',
            'attachment'    => 'mime_in[attachment,application/pdf]|max_size[3024]'

        if (!$this->validate($validationRules)) {
            return $this->fail($this->validator->getErrors());

which is working fine when I pass the attachment field, but since that field is optional, when I doesn't send it I get:

The file attachment does not have an allowed mime type

How can I manage this?

try to add the `permit_empty` rule

Theme © iAndrew 2016 - Forum software by © MyBB