Laravel 5.3 return custom error message using $this->validate()

前端 未结 4 1011
星月不相逢
星月不相逢 2020-12-05 14:09

How to return a custom error message using this format?

$this->validate($request, [
  \'thing\' => \'required\'
]);
4条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-05 14:35

    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']
    );
    

提交回复
热议问题