我做了注册表单,但是有一些是密码问题。我在密码字段中输入完全相同的密码并确认密码字段但它失败
java.lang.NullPointerException
at org.hibernate.transform.AliasToBeanResultTransformer.initialize(AliasToBeanResultTransformer.java:116)
at org.hibernate.transform.AliasToBeanResultTransformer.transformTuple(AliasToBeanResultTransformer.java:85)
at org.hibernate.hql.internal.HolderInstantiator.instantiate(HolderInstantiator.java:95)
at org.hibernate.loader.hql.QueryLoader.getResultList(QueryLoader.java:438)
at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2263)
at org.hibernate.loader.Loader.list(Loader.java:2258)
at org.hibernate.loader.hql.QueryLoader.list(QueryLoader.java:470)
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.list(QueryTranslatorImpl.java:355)
at org.hibernate.engine.query.spi.HQLQueryPlan.performList(HQLQueryPlan.java:196)
at org.hibernate.internal.SessionImpl.list(SessionImpl.java:1161)
at org.hibernate.internal.QueryImpl.list(QueryImpl.java:101)
at com.maps.manager.DatabaseManager.findAll(DatabaseManager.java:65)
at com.maps.manager.DatabaseManager.main(DatabaseManager.java:40)
我的注册表单
The password confirmation confirmation does not match.
我的验证
<div class="form-group">
{!! Form::password('password', ['class' => 'form-control','placeholder' => '*Password']) !!}
</div>
<div class="form-group">
{!! Form::password('password_confirmation', ['class' => 'form-control', 'placeholder' => '*Password Confirm']) !!}
</div>
我也试试这个
'password' => 'required|between:8,255',
'password_confirmation' => 'confirmed',
和这个
'password' => 'required|between:8,255',
'password_confirmation' => 'required|between:8,255|confirmed',
但仍无效
答案 0 :(得分:4)
这是确认密码的最佳方法:
'password' => 'required|between:8,255|confirmed'
说明:
已确认:正在验证的字段必须具有foo_confirmation的匹配字段。
例如, 密码字段,名称为:密码
密码确认字段为: password_confirmation
然后,confirmed属性将添加用于密码确认的默认检查。
答案 1 :(得分:2)
尝试
'password' => 'required|between:8,255|confirmed'
请注意,已确认已添加到密码验证中,您无需添加规则两次,因为确认字段需要具有相同的字段。
答案 2 :(得分:1)
您的验证应该是:
'password' => 'required | confirmed ',
'password_confirmation' => 'required ',
有关详细信息See Here
答案 3 :(得分:1)
confirmed
必须传递到password
验证规则:
'password' => 'required|between:8,255|confirmed',
'password_confirmation' => 'required',
答案 4 :(得分:0)
我正在使用Laravel 5.2 我可以使用
解决这个问题'password' => 'required|min:8|same:confirm_password'
答案 5 :(得分:0)
Validator::extend('old_password', function ($attribute, $value, $parameters, $validator) {
return Hash::check($value, current($parameters));
},
'Current password is wrong!'
);
$request->validate([
'old_password' => 'required|old_password:' . $user->password,
'password' => 'required|confirmed|min:6',
'password_confirmation' => 'required|same:password'
]);
答案 6 :(得分:-1)
$ validator_password =验证程序:: make($ request-> all(),[ 'old_password'=> ['required','string','min:8','old_password:'。 $ user-> password], 'new_password'=>'required | confirmed | min:6', 'password_confirmation'=>'必填|相同:new_password' ]);