$this->validate($request, [
'image_url' => ['required_without:image_upload', 'sometimes', 'nullable', 'active_url'],
'image_upload' => ['required_without:image_url', 'sometimes', 'nullable', 'image'],
]);
Oct 8, 2020
7
Level 1
"required_without" validation rule not working as expected
I have a validation like this:
$this->validate($request, [
'image_url' => ['required_without:image_upload', 'active_url'],
'image_upload' => ['required_without:image_url', 'image'],
]);
What I would like it to do is that you can either enter an image URL or upload an image.
If I enter an image URL, the validation goes through, as expected.
However, if I leave the image_url empty and select an image to upload, I get the error message:
The image url is not a valid URL.
Why is this? It shouldn't even check that, because it's not required (since I uploaded an image).
Level 75
1 like
Please or to participate in this conversation.