Laravel“至少一个"字段必填验证
本文介绍了Laravel“至少一个"字段必填验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我有这个包含这些字段的表单
So I have this form with these fields
我想告诉 Laravel,这些字段中至少有一个是必需的.我如何使用验证器做到这一点?
I'd like to tell Laravel that at least one of these fields is required. How do I do that using the Validator?
推荐答案
尝试检查 required_without_all:foo,bar,...
,看起来应该为你做.引用他们的文档:
Try checking out required_without_all:foo,bar,...
, it looks like that should do it for you. To quote their documentation:
只有在所有其他指定字段都不存在时,才必须存在正在验证的字段.
The field under validation must be present only when the all of the other specified fields are not present.
<小时>
示例:
这篇关于Laravel“至少一个"字段必填验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!