How to add validation in Laravel

/ Published in: PHP
Save to your folder(s)

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.

Copy this code and paste it in your HTML
  1. $validatedData = $request->validate([
  2. 'name' => 'required|max:255',
  3. 'username' => 'required|alpha_num',
  4. 'age' => 'required|numeric',
  5. ]);


Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.