Laravel required_if验证

时间:2018-02-21 06:27:45

标签: php laravel laravel-5

我想验证费用字段。如果 activity_code 值不是“SE”。它可以是任何值,但不是SE。

$rules = [
'cost' => 'required_if:activity_code,null',
'select_plans' => 'required_if:activity_code,SE',
];

2 个答案:

答案 0 :(得分:0)

$rules = [
'cost' => 'required_unless:prf_activity_code,!=,SE',
'select_plans' => 'required_if:activity_code,SE',
];

答案 1 :(得分:0)

  

您可以使用:

$rules = [
'cost' => 'required_unless:activity_code,SE',
'select_plans' => 'required_if:activity_code,SE',
];

$rules = [
'cost' => 'required_if:activity_code,!=,SE',
'select_plans' => 'required_if:activity_code,SE',
];