如何在Laravel中定义图像尺寸规则消息

时间:2019-07-09 15:52:18

标签: laravel validation lumen

我对POST请求具有以下图像验证,但我不确定如何为min_widthmin_heightratio添加定制验证消息吗?

protected function getRules(): array
{
    return [
        'logo' => 'required|file|mimes:jpg,jpeg,png|dimensions:min_width=400,min_height=400,ratio=1/1'
    ];
}

3 个答案:

答案 0 :(得分:1)

您需要这样定义您的消息:

'logo.dimensions' => 'The logo must be at least :min_width x :min_height pixels and have ratio :ratio',

答案 1 :(得分:0)

        'logo.dimensions' => 'The logo must be at least 400 x 400 pixels!',

答案 2 :(得分:-1)

您的验证:

"logo" => "dimensions:min_width=400,min_height=400"

您的表单,多部分/表单数据:

<form method="POST" enctype="multipart/form-data"></form>