Support the ongoing development of Laravel.io →
posted 3 months ago
Validation
0

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!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.