我想验证两个字段,即“类型”和“选项”,其中“类型”字段是枚举。仅当 'type' 字段的值为 'opt' 时,才应验证 'options' 字段。
$this->validate($request, [
'type' => 'required|in:opt,number,text,file,image',
'options'=>the condition I need(if type is 'opt')
]);
Run Code Online (Sandbox Code Playgroud)