Laravel 5.3使用$ this-> validate()返回自定义错误消息 [英] Laravel 5.3 return custom error message using $this->validate()
本文介绍了Laravel 5.3使用$ this-> validate()返回自定义错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用这种格式返回自定义错误消息?
How to return a custom error message using this format?
$this->validate($request, [
'thing' => 'required'
]);
推荐答案
要获取自定义错误消息,您需要在第三个参数上传递自定义错误消息,例如
to get custom error message you need to pass custom error message on third parameter,like that
$this->validate(
$request,
['thing' => 'required'],
['thing.required' => 'this is my custom error message for required']
);
这篇关于Laravel 5.3使用$ this-> validate()返回自定义错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文