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

前端 未结 4 1003
星月不相逢
星月不相逢 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:44

    For Multiple Field, Role and Field-Role Specific Message

    $this->validate(
            $request, 
            [   
                'uEmail'             => 'required|unique:members',
                'uPassword'          => 'required|min:8'
            ],
            [   
                'uEmail.required'    => 'Please Provide Your Email Address For Better Communication, Thank You.',
                'uEmail.unique'      => 'Sorry, This Email Address Is Already Used By Another User. Please Try With Different One, Thank You.',
                'uPassword.required' => 'Password Is Required For Your Information Safety, Thank You.',
                'uPassword.min'      => 'Password Length Should Be More Than 8 Character Or Digit Or Mix, Thank You.',
            ]
        );
    

提交回复
热议问题