Return to site
· Custom Validation,Form Request,validation rules,Methods,Laravel
broken image

We are familiar with using validator in controller which is the common way but this is not a good practice. Laravel has form request which is a special request class containing the validation logic. You can create form request using artisan command.

This command will create a new Request class in app\Http\Request\UserRequest .

Those who are not familiar with this method will get confused easily when you first use it.

So we will see how to add custom validation rules in form request method.

Example:

You want to add a custom validation numeric_array with field items

'shipping_country' => ['max:60'],

'items' => ['array|numericarray']

];

The custom function is :Read more