Laravel 5 - validate array as required, but allow an empty array to be passed

1) Array is required

2) Value of all array is not null or empty

public static $rules = [
   'category' => 'required|array|min:1',
   'category.*' => 'required',
];

probably this should work

public function rules()
{
   return [
    "items"    => "required|array|min:0",
    "items.*"  => "required|string|distinct|min:0",
  ];
}

Try:

public function createSomeResource(Request $request)
{
    $this->validate($request, [
        'items' => 'required|array|min:1',
    ];
    ...
}

From Laravel doc:

min:value The field under validation must have a minimum value. Strings, numerics, arrays, and files are evaluated in the same fashion as the size rule.


Try this:

public function createSomeResource(Request $request)
{
    $this->validate($request, [
        'items' => 'present|array',
    ];
    ...
}