如果第一个输入在laravel验证中失败,则停止验证第二个输入 [英] Stop Validate the second input if the first input failed in laravel validation
问题描述
我有两个要验证的输入(密码,电子邮件).是否可以检查密码字段验证是否失败不验证电子邮件字段?
I have two inputs (password , email) which i want to validate them. Is it possible to check if the password field validations failed Don't validate email field?
public function rules()
{
return [
'password' => 'required|validate_client_password',
'email' => 'required|email|max:255'
];
}
推荐答案
签出 required_with 和 required_with_all 和...
这可能可以解决您的问题.
This may be resolve your problem.
required_with:foo,bar,...
required_with:foo,bar,...
要验证的字段必须存在,并且只有在存在其他指定字段的情况下,才可以为空.
The field under validation must be present and not empty only if any of the other specified fields are present.
required_with_all:foo,bar,...
required_with_all:foo,bar,...
要验证的字段必须存在,并且只有在所有其他指定的字段都存在的情况下,才可以为空.
The field under validation must be present and not empty only if all of the other specified fields are present.
https://laravel.com/docs/5.6/validation
致谢.
这篇关于如果第一个输入在laravel验证中失败,则停止验证第二个输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!