Only until March 18th: coupon LARAVEL12 for 40% off Yearly/Lifetime membership!

Read more here

Stop on First Validation Error

By default, Laravel validation errors will be returned in a list, checking all validation rules. But if you want the process to stop after the first error, use validation rule called bail:

$request->validate([
'title' => 'bail|required|unique:posts|max:255',
'body' => 'required',
]);

If you need to stop validation on the first error in FormRequest class, you can set stopOnFirstFailure property to true:

protected $stopOnFirstFailure = true;

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 71 courses
  • 93 long-form tutorials
  • access to project repositories
  • access to private Discord

Recent New Courses