0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Laravel10 Password再設定 現在のパスワードと再設定用のパスワードと確認用パスワードの3入力の効率よくバリデーションの記述方法

Posted at

password再設定 現在のパスワードと再設定用のパスワードと確認用パスワードの3入力の効率よくバリデーションの記述方法

$request->validate([
'old_password' => ['required', 'current_password'],
'new_password' => ['required', 'confirmed', '...略...'],
]);

これで、old_passwordが現在認証済みユーザーのパスワードと等しいかどうかを検証できます。もし一致しなければ、エラーメッセージを表示できます。

passwordというフィールドと、password_confirmationというフィールドが同じ値である必要があります。password_confirmationというフィールドは、フォームに用意する必要があります。

現在のパスワードのnameにcurrent_password
新しいのパスワードのnameにpassword
確認用のパスワードのnameにpassword_confirmation
に設定し 上記の validationを記述する

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?