mardi 10 septembre 2019

Adding error message manually in Laravel Validation

I am trying to add new error message in my validation if the user failed to input correct current password. Here is the code i am working on:

  $validator = $this->validate($request, [
        'current-password' => 'required',
        'password' => 'required|string|min:6|confirmed',
    ]);


  if (!(Hash::check($request->get('current-password'), Auth::user()->password))) {
      $validator->errors()->add('current-password', 'Your current password does not matches with the password you provided. Please try again.');
    }

I am getting this error when i submit the form: Call to a member function errors() on array

Any help would be appreciated. Thanks.



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2HZRZrw
via IFTTT

Aucun commentaire:

Enregistrer un commentaire