在Laravel 中驗證陣列
嘗試使用以下程式碼在Laravel 中驗證數個群組時:
$validator = Validator::make($request->all(), [ "name.*" => 'required|distinct|min:3', "amount.*" => 'required|integer|min:1', "description.*" => "required|string" ]);
$validator = Validator::make($request->all(), [ "names" => "required|array|min:3", "names.*" => "required|string|distinct|min:3", ]);
嘗試使用以下程式碼在Laravel 中驗證數位時:
$data = $request->validate([ "names" => "required|array|min:3", "names.*" => "required|string|distinct|min:3", ]);
以上是如何在 Laravel 中驗證陣列:空提交和最佳實踐?的詳細內容。更多資訊請關注PHP中文網其他相關文章!