0

I have used validation for image in Laravel Voyager BREAD. But it doesn't work. It takes all dimension of images.

Here is my code

{
"validation": {
    "rule": "dimensions:width=100,height=100",
    "messages": {
        "dimensions": "This :attribute field is a must."
    }
}
}

Image for more clarification:

image

JonathanDavidArndt
  • 2,518
  • 13
  • 37
  • 49
raff
  • 423
  • 4
  • 13
  • 28

2 Answers2

0

From the docs you need to add mimes rule, and use dimensions rule like:

'rule' => 'mimes:jpeg,bmp,png|dimensions:width=340,height=960'
Mahdi Younesi
  • 6,889
  • 2
  • 20
  • 51
0

You can try a creating a rule since this requires several arguments

 use Illuminate\Validation\Rule;

    Validator::make($data, [
        'image' => [
            'required',
            Rule::dimensions()->maxWidth(1000)->maxHeight(500)->ratio(3 / 2),
        ],
    ]);
Shobi
  • 10,374
  • 6
  • 46
  • 82
  • I am using Laravel Voyager admin panel. There are some validation specific rules. You have got the idea from [https://voyager.readme.io/docs] – raff Feb 15 '18 at 09:21