What is validations in laravel?
In Programming validations are a handy way to ensure that your data is always in a clean and expected format before it gets into your database.
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.
Laravel validation Example:
1 2 3 4 5 | $validatedData = $request->validate([ 'name' => 'required|max:255', 'username' => 'required|alpha_num', 'age' => 'required|numeric', ]); |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.