LoginSignup
0
0

More than 1 year has passed since last update.

Laravel バリデーション パスワードでは半角英数字記号・・・

Posted at

Lravel に限った事ではないのですが、パスワードの入力チェックで
1. 必須
2. 8文字以上
3. 半角英数字記号を1文字以上含むこと
4. 確認入力のものと一致すること
なんてものがあります(4はもう古いチェックかもしれませんが)。

以下で解決します。

'rules' = [
'password'                  => 'required|confirmed|between:8,128|regex:/\A(?=.*?[a-z])(?=.*?\d)(?=.*?[!-\/:-@[-`{-~])[!-~]+\z/i',
];

'attr' = [
'password'                  => 'ログインパスワード',
];

'msg' = [
'password.regex'            => ':attributeは半角英数字記号それぞれ一文字以上使用してください',
そのほかメッセージ
]

間違ってましたらご指摘お願いします。

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