3
0

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.

【Laravel】同値チェックのバリデーション

Posted at

はじめに

確認用の入力でバリデーションがしたく、同値チェックができるもののまとめ

same:フィールド名

指定したフィールドと同じ値であるかどうか

'name' => ['same:confirm']

different:フィールド名

指定したフィールドと異なる値であるかどうか

'sub_email' => ['different:main_email']

confirmed

[フィールド名]_confirmationフィールドと同値であるかどうか

'email' => ['required', 'confirmed']

入力確認用に使用するものであるが、[フィールド名]_confirmationの存在が必要となる
上記だとemail_confirmationが必要

メールアドレス<input type="text" name="email">
メールアドレス(確認用)<input type="text" name="email_confirmation">

以上

3
0
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
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?