參考 官方文件
$rules = [
'type' => 'required|in:1,2',
'from' => 'required_if:type,1|numeric',
'to' => 'required_if:type,1|numeric',
'shippingMethod' => [Rule::requiredIf(function () use ($request) {
return ($request->from == 1 && $request->to == 1);
}),'numeric'],
'keyword' => 'required_if:type,2',
'vendorIds' => 'nullable|regex:/^[0-9,]+$/',
'categoryIds' => 'nullable|regex:/^[0-9,]+$/',
'pickupDate' => [Rule::requiredIf(function () use ($request) {
return ($request->from == 1 && $request->to == 1);
}),'regex:/^[0-9\-]+$/'],
'lang' => 'nullable|in:en,jp,kr,th',
];