The nullable
& file
rules aren't compatible with each other (if the field is missing from the request, the file
rule will trigger regardless of whether nullable
is in the ruleset).
I think this is because the under the hood, those fields will arrive in the $_FILES
superglobal instead of the $_POST
. There is an example of handling this by validating any file uploads separately to the standard fields in the store
method here: https://github.com/musimana/bassform/blob/main/app/Http/Controllers/Public/PageController.php (I left it in the controller since it's just an example method, but it could easily be moved to a FormRequest
).
If anyone knows a more 'Laravelly' way to do it then I'd love to know!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community