File validation on frontend

My model is defining the $rules

'resume' => 'required|file|mimes:pdf|max:2048',

the frontend it defining the input file

 <form
        data-request="{{ __SELF__ }}::onSave"
        data-request-validate
        data-request-flash
        data-request-files>
....
<input type="file" name="resume" accept="application/pdf" />

....
</form>

and whether I choose a file or not, the validation never passes, and it triggers the data validation error:

The resume field is required.

what am I doing wrongly here ?

The problem might be, that you are validating the model and not the request. I guess you are using the model file attachment relationship. That means that you first have to make the model, attach the uploaded file and then validate.

If you want to validate the uploaded file during the request, either create your own validator (Validator::make()) or use the Request::validate() method described here: File Uploads - October CMS - 3.x

1 Like

yes you are right, I did a request validation and it worked out well, thanks @marco.grueter