Return to Snippet

Revision: 80165
at February 13, 2020 06:30 by devquora


Initial Title
How to add validation in Laravel

Initial Description
Laravel provides several different ways to validate your application incoming data.By default Laravel’s base controller class uses a ValidatesRequests trait which provides a convenient method to validate all incoming HTTP requests coming from client.You can also validate data in laravel by creating Form Request.

Initial Code
$validatedData = $request->validate([
            'name' => 'required|max:255',
            'username' => 'required|alpha_num',
            'age' => 'required|numeric',
        ]);

Initial Tags
php

Initial Language
PHP

Initial URL
https://www.onlineinterviewquestions.com/laravel-interview-questions/