Support the ongoing development of →
posted 3 months ago

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: (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!


Your banner here too?


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

Your logo here?

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

© 2024 - All rights reserved.