问题
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'
];
}
回答1:
Check out required_with and required_with_all and ...
This may be resolve your problem.
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,...
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
Regards.
来源:https://stackoverflow.com/questions/47391776/stop-validate-the-second-input-if-the-first-input-failed-in-laravel-validation