Laravel sometimes validation rule

后端 未结 7 2185
孤街浪徒
孤街浪徒 2021-02-08 07:38

I am trying to validate a password field only if it is present. I want to allow someone to edit a user and they may or may not want to change the users password. So I thought I

7条回答
  •  孤独总比滥情好
    2021-02-08 08:24

    As an option to the selected answer, you can use:

        $this->validate($request, [
           'password' => 'nullable|min:8',
        ]);
    

提交回复
热议问题