Request Validation using Form Request in Laravel.

First of all, we have to make a request class by below command

php artisan make:request

Now, we have to load the custom request file into the controller for that we have to copy and paste the namespace from form request class to controller. See the below image:-

After that, we write our request in rules function under the return array. See below:-

To write the customise code we have to make a function named message in which we write our customised message under the return array. See the below code:-

See when we provide invalid email then our customised message appears or not:-

Output

Now See the output whether it returns a message when we did not provide value in the given field.

Now, When we fill 1-2 field and left other then what message returns. See below:-

When we fill all the fields, then what returns:-