Laravel Validation for Array Example

Laravel 6 , Laravel

Nicesnippets

159

16-12-2019


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.....


Recommended Posts