phplaravelvalidationlaravel-validation

How to return custom error message from controller method validation


How to return a custom error message using this format?

$this->validate($request, [
  'thing' => 'required'
]);

Solution

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