Verdemis's avatar

Validating image with matching min_height OR min_width

Hello everybody,

I'm trying to validate an uploaded image and the image has to mtacht the min_width OR the min_height. Is there a way to do this with the laraval validator?

Best, Verdemis

0 likes
2 replies
AddWebContribution's avatar

You should try this:


// ImageController
    public function postImage(Request $request)
    {
        $this->validate($request, [
             'avatar' => 'dimensions:min_width=250,min_height=500'
        ]);

        // or... 

        $this->validate($request, [
             'avatar' => 'dimensions:min_width=500,max_width=1500'
        ]);

        // or...

        $this->validate($request, [
             'avatar' => 'dimensions:width=100,height=100'
        ]);

        // or...

        // Ensures that the width of the image is 1.5x the height
        $this->validate($request, [
             'avatar' => 'dimensions:ratio=3/2'
        ]);
    }

Please or to participate in this conversation.