我想根据另一个字段添加验证字段,如:
pay_time
=> “必需的”,
"months" => "rules:pay_time"
当pay_time是每月,月份是1,2,3,4,....但如果pay_time是年度,月份应该是12,24,36,...
如何将pay_time值传递给扩展验证功能?
答案 0 :(得分:0)
我认为使用其他字段添加年度值的更好方法是其他名称,然后您可以使用required_if
规则对其进行验证。
[
pay_time => "required|in:monthly,yearly",
months => "required_if:pay_time,monthly|in:1,2,3,4,5,6,7,8,9,10,11",
years => "required_if:pay_time,yearly|in:12,24,36,48",
]