Laravel密码&密码确认确认 [英] Laravel Password & Password_Confirmation Validation

查看:126
本文介绍了Laravel密码&密码确认确认的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用它来编辑用户帐户信息:

I've been using this in order to edit the User Account Info:

$this->validate($request, [
    'password' => 'min:6',
    'password_confirmation' => 'required_with:password|same:password|min:6'
]);

这在Laravel 5.2应用程序中工作正常,但在5.4应用程序中无效.

This worked fine in a Laravel 5.2 Application but does not work in a 5.4 Application.

这是怎么回事?或者仅在设置了passwordpassword_confirmation字段的情况下才使password成为必需的正确方法是什么?

What's wrong here, or what is the correct way in order to only make the password required if either the password or password_confirmation field is set?

推荐答案

您可以使用确认验证规则.

$this->validate($request, [
    'name' => 'required|min:3|max:50',
    'email' => 'email',
    'vat_number' => 'max:13',
    'password' => 'required|confirmed|min:6',
]);

这篇关于Laravel密码&密码确认确认的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆