【发布时间】:2015-10-10 22:43:36
【问题描述】:
如何在验证器中添加密码验证规则?
验证规则:
密码包含来自以下五类中的至少三类的字符:
- 英文大写字符 (A – Z)
- 英文小写字符 (a – z)
- 以 10 位为基数 (0 – 9)
- 非字母数字(例如:!、$、# 或 %)
- Unicode 字符
如何在验证器规则中添加上述规则?
我的代码在这里
// create the validation rules ------------------------
$rules = array(
'name' => 'required', // just a normal required validation
'email' => 'required|email|unique:ducks', // required and must be unique in the ducks table
'password' => 'required',
'password_confirm' => 'required|same:password' // required and has to match the password field
);
// do the validation ----------------------------------
// validate against the inputs from our form
$validator = Validator::make(Input::all(), $rules);
// check if the validator failed -----------------------
if ($validator->fails()) {
// get the error messages from the validator
$messages = $validator->messages();
// redirect our user back to the form with the errors from the validator
return Redirect::to('home')
->withErrors($validator);
}
【问题讨论】:
-
不能每个字符都表示为一个unicode字符吗?
-
您可能会发现Reference - Password Validation 很有用。
标签: php laravel validation laravel-5