Define Validation in Laravel with Example

In this tutorial i’m going to describe what is Validation and how to using in to project.

Laravel provides several different approaches to validate your application’s incoming data. By default, Laravel’s base controller class uses a ValidatesRequests trait which provides a convenient method to validate incoming HTTP request with a variety of powerful validation rules.

Laravel provide several pre-define validation rules that way we can user it simply. In this example i used some validation rules that listed bellow that need to apply.

1)required: for must be required field.

2)min: for limit to enter minimum character.

3)max: for limit to enter maximum character.

4)mail: for check only email allow.

5)unique: for check with database table unique column.

6)numeric: for allow only numeric value.

7)same: for two fields value must be match.

Let’s first to install Project

After installation migrate the tables

Next go to your routes/web.php and paste below code

Next to Add Controller

Create HomeController

Ok, now we write two method in HomeController as listed bellow:



In first method formValidation() we will just return view and in second method formValidationPost() we will write from validation rules.

I use $this->validate() method of Controller class and it take three argument like as bellow syntax:

Next go to your Controller file and paste below code


Next to create blade files resources/views/form-validation.blade.php

Now Blade files as look like

Now fill your input


Hi I am Amit Experienced Web Developer with a demonstrated history of working in the information technology and services industry.