Laravel

Object array 유효성 검사하는법

짱구를왜말려? 2020. 7. 19. 19:24
반응형
SMALL
      $request->validate([
            "menus" => "required|array|max:100",
            "menus.*.title" => "required|string|max:500",
            "menus.*.body" => "required|string|max:500",
            "menus.*.price" => "required|integer|min:0",
        ]);
        
     /*
     $menus = [
            [
                "title" => "test",
                "body" => "test",
                "price" => 1000,
            ],
            [
                "title" => "test",
                "body" => "test",
                "price" => 1000,
            ],
        ]
     */
LIST