Laravel Validation for Array Example

Share Me
  •  
  •  
  •  
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share
Laravel Validation for Array Example

Hi Dev’s,
Today now in this example, I want to share with you how to make validation for array in laravel application. So we can do this very simple and easy to set validation for array length in laravel.

Now we can create to one or more fields in laravel form. We can set to name of field in laravel form. Now this validation check array format value.

Example

We can apply to logic in our 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
}

Read Also : How To use Bootstrap Timepickar Example Code ?

I hope it will help you. Also you can follow us on Facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →