Stop Validate the second input if the first input failed in laravel validation

▼魔方 西西 提交于 2019-12-11 04:26:13

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!