Validation not working in laravel 5.5
Stefan Bogdanescu
Founder & Senior Architect · 2026-06-29
Debugging Form Validation Failures in Laravel 5.5: A Deep Dive
As developers transition between major framework versions, it’s common to encounter subtle breaking changes, especially when dealing with core features like form validation. The issue you are facing—where form submissions result in a page reload without any error feedback, even after removing the validation rules—suggests a breakdown in the request lifecycle rather than a simple syntax error.
This post will walk through the common pitfalls when implementing validation in Laravel 5.5 and provide a thorough diagnosis and solution for your specific scenario.
Understanding the Validation Flow in Laravel
The core of your problem lies in understanding exactly when and how $this->validate() executes within your controller. In a typical Laravel setup, validation is designed to halt execution if the incoming request data does not meet the specified rules (e.g., required, min:10). If validation fails, Laravel automatically redirects the user back to the previous page, flashing the error messages.
Let's review the structure you provided:
The View (test.blade.php):
<form method="POST" action={{ route('contact') }}>
{{ csrf_field() }}
<input type="text" name="title">
<input type="text" name="body">
<input type="submit" value="click">
</form>
The Controller (PageController):
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class Pagecontroller extends Controller
{
public function index(Request $request){
$this->validate($request,[
'title' => 'required',
'body' => 'required',
]);
return View('View'); // This line only runs if validation succeeds
}
}
The Route (web.php):
Route::post('/contact',['uses'=>'PageController@index','as'=>'contact']);
Diagnosing the Validation Failure
When you submit the form with empty fields, and nothing happens (just a reload), it strongly suggests one of two things is happening:
- Validation Failure is Suppressed: The validation rules are failing, but instead of triggering the standard redirection with errors, something is intercepting or swallowing the error response.
- Request Binding Issue: Less likely in this simple setup, but sometimes issues arise if route model binding or request object handling changes between major versions (like 5.4 to 5.5).
Since you noted it worked in Laravel 5.4, the change in behavior often relates to how middleware interacts with the routes and controller execution path in the newer version.
The Correct Approach: Handling Validation Errors Explicitly
If $this->validate() is not yielding the expected error messages upon failure, the most robust solution is to explicitly check for validation errors immediately after the call. This forces you to handle the failure state directly within your code, which is essential for debugging and providing a good user experience.
Here is how you can modify your index method to ensure proper error handling:
use Illuminate\Http\Request;
class Pagecontroller extends Controller
{
public function index(Request $request){
// Attempt validation
$this->validate($request,[
'title' => 'required',
'body' => 'required',
]);
// If validation passes, proceed with the view
return View('View');
}
}
Wait—if this still doesn't work, the issue might be related to how the underlying request is being processed. In complex scenarios, developers often look into using Form Requests, which is a cleaner separation of concerns recommended by the Laravel team for handling form data validation. Following best practices, you should explore using dedicated Form Request classes instead of placing validation directly in the controller method. For more advanced structure and adherence to modern principles, exploring concepts like those promoted on laravelcompany.com is highly beneficial.
Best Practice: Migrating to Form Requests
For handling form data, especially when dealing with complex validation rules or separating logic from controllers, Laravel strongly recommends using Form Requests. This keeps your controller lean and makes your validation rules reusable across different routes.
Step 1: Create the Request Class
php artisan make:request ContactRequest
Inside app/Http/Requests/ContactRequest.php:
namespace App\Http\Requests;
use Illuminate\Http\Request;
class ContactRequest extends Request
{
public function authorize()
{
return true; // Only validate if authorized
}
public function rules()
{
return [
'title' => 'required',
'body' => 'required',
];
}
}
Step 2: Update the Controller
Now, update your controller to inject and use this request class. This method is cleaner, more testable, and ensures that validation errors are automatically handled by Laravel upon failure.
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests\ContactRequest; // Import the new Request
class Pagecontroller extends Controller
{
public function index(ContactRequest $request){
// If we reach this point, validation has already passed successfully.
// No need for explicit $this->validate() call here!
return View('View');
}
}
By adopting Form Requests, you move away from manually calling $this->validate() and rely on Laravel's built-in request handling mechanisms, which mitigates version-specific issues and enforces a cleaner structure for your application. Always strive to use the tools provided by the framework, as promoting consistent architecture is key to long-term maintainability, much like the principles discussed at laravelcompany.com.
Conclusion
The issue you faced with validation not working reliably in Laravel 5.5 likely stems from subtle differences in request lifecycle management or middleware interaction between versions. While debugging involves inspecting the full stack trace, the most robust fix is to adopt modern Laravel practices. By migrating your validation logic into dedicated Form Requests, you ensure that your application remains clean, predictable, and resilient across framework updates. This approach simplifies development and aligns with the best practices advocated by the Laravel community.