我是Laravel的新人。我想仅在用户在密码文本字段中输入一些值时才执行验证检查。否则,请勿对密码字段执行验证检查。
我搜索了类似的问题,但没有找到任何满意的答案。
提前感谢您的帮助。
更新:这是我的验证代码
if x_egg + egg_radius > x_pos and \
x_egg + egg_radius < x_pos + x_size and \
y_egg - egg_radius >= y_pos and \
y_egg + egg_radius <= y_pos + y_size:
caught_egg = True
y_egg = 0
x_egg = InitEgg()
答案 0 :(得分:1)
不要使用required
规则
"password" => "min:6 | max:12"
只有填写了密码字段,密码的长度才为6到12个。
答案 1 :(得分:-1)
如果您愿意,可以尝试使用此代码:
if(!empty($request->input('password'))){
// perform the validation with password
} else{
// perform the validation without password
}