I have a FormRequest class like below
<?php
namespace App\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class StoreImageRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return [
'uploadImage' => 'image|mimes:jpg,png,jpeg,|max:2048',
];
}
}
How can I get validation message here ? Like if the file is not an Image
or the file size is not within max:2048
.
Thanks
override the messages()
method in the StoreImageRequest.php
.
public function messages()
{
return [
'uploadImage.mimes' => 'Custom error message.',
];
}
laravel doc here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With