What is form validation in Laravel?
Why Interviewers Ask This
Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Laravel basics — a prerequisite for any developer role.
Answer
Laravel provides a powerful validation system. The simplest approach is $request->validate(["name" => "required|string|max:255", "email" => "required|email|unique:users"]). If validation fails, Laravel automatically redirects back with errors and old input. In Blade, display errors with @error("name") and repopulate with old("name"). For complex validation, use Form Requests: php artisan make:request StoreUserRequest — the validation logic lives in the rules() method, keeping controllers thin. Laravel has 70+ built-in validation rules: required, email, min:3, max:255, unique:table,column, exists:table,column, confirmed (password confirmation), image, mimes:jpg,png, date, numeric, regex, and many more.
Pro Tip
If you're unsure about a detail, say so honestly and explain your reasoning. Interviewers respect candidates who can think through uncertainty rather than bluffing.