Laravel Validation for Array Example

10-Apr-2023

.

Admin

Laravel Validation for Array Example

Hii Guys,

In this example,I want to show you validation for array in laravel. you can simply and easy to set validation for array length in laravel.

you can create to one or more fildes in laravel form. you can set to name of field in laravel form. This validation check array formate value.

Example


you can apply to logic in your controller.

/**

* The attributes that are mass assignable.

*

* @var array

*/

public function store(Request $request)

{

$input = $request->all();

$validator = $request->validate([

"name" => "required|array|min:3",

"name.*" => "required|string|distinct|min:3",

]);

// Write Logic

}

It will help you.....

#Laravel 7

#Laravel

#Laravel 6