【发布时间】:2020-06-15 10:56:09
【问题描述】:
我正在使用 JS Validator 在 Laravel 中验证我的表单字段
以下是我在用户控制器中用于验证的代码
class UserController extends Controller
{
protected $changepassValidationRules = [
'old_password' => 'required|pwdvalidation|min:6',
'password' => 'required|min:6|confirmed',
];
}
我通过$changepassValidationRules查看页面进行检查。
以下是我在视图页面中的代码
<div class="col-md-4 col-sm-6 col-xs-12">
<div class="card">
<form method="post" action="{{ url('user/changepassword') }}" name="useredit" id="changepass"
enctype="multipart/form-data" novalidate>
{{ csrf_field() }}
@if (session('message_changepass'))
<div class="alert alert-success">
{{ session('message_changepass') }}
</div>
@endif
<div class="card-header">
<h4 class="card-title">
Change Password
</h4>
</div>
<div class="card-content">
<div class="form-group {{ $errors->has('old_password') ? ' has-error' : '' }}">
<label class="control-label">Old Password
<star> *</star>
</label>
<input type="password" placeholder="Password" class="form-control" id="old_password"
name="old_password">
@if ($errors->has('old_password'))
<span class="help-block error-help-block">
{{ $errors->first('old_password') }}
</span>
@endif
</div>
<div class="form-group {{ $errors->has('password') ? ' has-error' : '' }}">
<label class="control-label">New Password
<star> *</star>
</label>
<input type="password" placeholder="Password" class="form-control" id="password" name="password">
@if ($errors->has('password'))
<span class="help-block">
{{ $errors->first('password') }}
</span>
@endif
</div>
<div class="form-group">
<label class="control-label">Confirm Password
<star> *</star>
</label>
<input id="password-confirm" type="password" class="form-control" name="password_confirmation"
placeholder="Confirm Password">
</div>
<div class="form-action">
<button type="submit" class="btn btn-fill btn-info">Submit</button>
</div>
</div>
</form>
</div>
所有其他验证规则都运行良好,但问题是我想验证数据库中已经存在的当前密码。
如果用户输入错误的密码应该抛出错误,这是什么问题
【问题讨论】:
-
pwdvalidation是什么?