New Package: Laravel Fluent Validation - Performance Demo (Before/After)
Chapters12
Introduce the Laravel Fluent Validation package and its author and motivation for a dedicated validation package.
A practical look at Laravel Fluent Validation by Sander Mueller, showing dramatic performance gains on large arrays and practical syntax benefits.
Summary
Laravel Daily’s video, hosted by Taylor Marcus (the channel’s host), introduces a new package called Laravel Fluent Validation by Sander Mueller. The host compares the familiar Laravel validation syntax with the fluent approach, highlighting IDE autocomplete and easier rule chaining as key benefits. He walks through two demo scenarios: a regular Laravel form request and a fluent version, focusing on large arrays of data (500 products and 5 variants). The benchmarks emphasize two core claims from the package: faster validation for big arrays and batched database validation that minimizes queries. In the first test, both approaches log roughly similar wall-clock time, but the fluent version reduces database queries through batched validation. In the second, the fluent approach dramatically lowers query counts—from thousands to just a few—and cuts total time to about 85 ms. He also points to the readme as a deep resource and notes that the package supports features like migrating existing Recursor validation, Livewire integration (has fluent validation trait), and Nesting options such as each and children for complex array schemas. Throughout, Mueller’s community-facing momentum is apparent as Taylor shares a teaser about Upwork Laravel jobs and reminds viewers how large the readme is, signaling this isn’t a light-weight library. Overall, the video offers a concrete before/after demonstration grounded in real data and points to broader use cases where exists/unique rules can trigger heavy database activity.
Key Takeaways
- Fluent Validation by Sander Mueller enables IDE autocomplete for Laravel validation, reducing the need to remember rule names.
- The package can dramatically reduce database queries for large arrays through batched validation, as shown in the 500-product benchmark.
- In one scenario, fluent validation reduced queries from thousands to just two, with total time around 85 milliseconds.
- Benchmarks compare regular Laravel requests to fluent ones, highlighting performance when validating arrays with nested structures (products and variants).
- The readme documents migration paths from Recursor validation and shows Livewire/Filament integration options.
- Fluent syntax supports nested rules like each, children, and unknown entries, improving readability for complex arrays.
Who Is This For?
Essential viewing for Laravel developers dealing with large form arrays or complex nested validation, especially when exists/unique rules would otherwise explode with database queries. Also useful for teams evaluating new validation ergonomics and performance improvements.
Notable Quotes
"You don't need to remember the rules and the syntax like required with all or something. It's autocompleted with IDE."
—Highlighting IDE autocomplete as a primary usability benefit.
"The package claims to be up to 160x faster and 62x faster."
—Cites the performance claims the package makes.
"This is where the batched database validation reduces the number of queries."
—Explains the core optimization technique.
"If we compare that to regular import product request, this is a typical old school... the data for that form request for validation is kinda faked in the benchmark controller."
—Describes the benchmarking setup and data feeding method.
"Two database queries instead of n queries and the total time is 85 milliseconds."
—Key benchmark result for the fluent approach.
Questions This Video Answers
- How does Laravel Fluent Validation differ from the built-in validation rules in Laravel?
- Can batched database validation really reduce the number of queries in large arrays?
- What are the best practices for migrating existing Laravel validation to Laravel Fluent Validation?
- How do I use each and children for validating nested arrays in Laravel?
- Is Laravel Fluent Validation compatible with Livewire and Filament projects?
Laravel Fluent ValidationLaravelPerformance benchmarkingBatch validationBatc hed database validationLivewire integrationFilamentEloquent exists/unique optimizationIDE autocompleteRecursor migration
Full Transcript
Hello guys, in this video I want to show you a new Laravel package called Laravel Fluent Validation by Sander Mueller from the Netherlands. And you would think that validation is nothing really fancy and why a separate package for Laravel validation. But look at this syntax. So you see the before and after and the package has a few purposes. First is syntax. So you don't need to remember the rules and the syntax like required with all or something. It's autocompleted with IDE. So it's easier to chain the rules just the syntax. So in the readme there's a section why this package and one of the reason is this.
So you don't need to remember those rule names but then also it is faster if you have a validation on large arrays and this is what I will demonstrate in this video. The package claims to be up to 160x faster and 62x faster. Of course, these are huge numbers and I will try to test it on big arrays. And when I shared that package on Twitter a few weeks ago, it got quite a few likes with definitely trying and very nice comments. So I think this should be beneficial for the Laravel community. So this is the demo project and I will show you two experiments before and after.
So imagine there's a form to create an event and then there are attendees which you need to validate. So array of attendees with their email and name and age and other columns and in the code in the controller there are two form requests. So typical create event request the old school the regular Laravel array validation with asterisk here and with separator but you can do that in array as well. So this is without the package and then I have another fluent create event request which uses the package. So as you can see you have a few use things.
So use has fluent rules and then the rules look like this. So this is the regular chain of rules for fields and then attendees is array and then the array itself has the rules of minimum and maximum for example but then each column looks like this. It may be a personal preference which one is more readable but this is at least has ID support. So for example you can do array here something like that. So this is not AI autocomplete. This is IDE autocomplete in my VS code from the package. But what I wanted to show you is the performance before and after with one and another form request class.
How many database queries will there be executed? So with regular create event request, we create event and then it will log how much it took 22 milliseconds with 11 queries. And kind of a side lesson how those queries are measured. So there's request measurement and that request is in the create event request and this is a trait measures validation. So what is done? Prepare for validation. So this is executed before the validation starts and then we count the database queries. We enable the log and count the queries at the start. But then past validation counts the same thing after validation is passed.
And then that request measurement basically calculates the difference in both milliseconds for time and amount of queries. And this is what we see in the controller here request measurement. So yes, in this case we have 11 database queries. Now let's change the form request to fluent create event request and let's repeat the same thing. So it was 22 milliseconds with 11 queries. Refresh the form. It is autofilled in just to save time. And what do we have here now? The millisecond time is roughly the same because it's not about database queries and it's not a big difference and I will show you a bigger difference in the second example.
But the amount of queries is different and that number of queries is optimized with this function of the package batched database validation. By the way, the readme is huge and you can read it in full. If we navigate to this, this is explained how that validation of X records is optimized and only the needed queries are actually executed. If I understand correctly, it's kind of similar to eager loading in Eloquent. And then another example, benchmark. I will run benchmark on 500 products and five variants again with two different form request classes. But before we go there, I want to tell you about something that I started for freelance Laravel developers.
This is kind of a portion of YouTube video usually sponsored by something. So it's not really sponsored, but I don't want to leave it at the end of this video. So many people usually don't stay until the very end. So I want to tell you about Upwork Laravel jobs. So if you are a freelancer or want to be a freelancer on Upwork but not necessarily I started a daily newsletter where I pick by hand Laravel jobs something like this from Upwork. So every morning there's like three to five best in my opinion jobs for Laravel developers or projects or some projects that are suitable for Laravel not necessarily text tag specified.
So this is one example. This is another example from another day and also some tip for Upwork if I notice something about the platform. And this is useful not only if you want to pitch on Upwork because you may not like some pricing because it's not ideal or just generally don't want to compete with like 50 other candidates but just to understand the market. What are the types of projects for Laravel? What are similar text tag? I know that some people reply to these email like thanking me not for Upwork recommendations but for general understanding what they need to learn to be better with Laravel and to get the chance to get some projects like that not necessarily from Upwork but in general.
So yeah, if you want to get that every morning it's free. It's Laravel Daily Comm newsletter. The link will be in the description below. Now back to the video. So this is the controller for benchmark. This is not strictly a form but it's a simulation of form request. Fluent import product request. This is for importing products versus not fluent. So if we have fluent here the validation is for products as array and then a lot of stuff inside of array and also there's variance which is also array. So multi-dimensional and also here we have exists and unique which will be optimized.
Right? And if we compare that to regular import product request, this is a typical old school still working with asterisk also asterisk on second level. Same rule exists, same rule unique and same rule in and the data for that form request for validation is kind of faked in the benchmark controller in the show method. This is here. So payload builder builds the big array of 500 products and five variants each. So this is pretty huge and this is passed to the blade view. So it's already passed to the request here. So anyway let's start with fluent import product request and if we run the benchmark these are the numbers again two database queries instead of n queries and the time the total time is 85 milliseconds.
Now let's change that to regular import product request without the package and let's repeat the same run benchmark and it's slower thousand database queries and close to 1 second time. So yeah this would be my main use case for this package in my opinion. If you have validation for big arrays especially with exists or unique rules which may trigger a lot of database queries then yeah fluent validation may be better but this package has many more features inside. As I said the readme is pretty huge. So for example you can migrate existing validation with recctor to fluent validation.
Then it also has livewire has fluent validation trait for livewire and then something for filament also rules for laravel boost the guidelines and a lot of syntax options like for example one more thing I wanted to show you from the docs is this each and so you can do fluent rule required each if you validate the array with unknown number of entries or even nested arrays like this each and then each but also there's children. So the object with known keys not a wildcard array. So instead of this this is maybe a better structure. So even visibly this is an array and this is not exactly.
So it's maybe a bit harder to read and you can combine that in something like this. So columns and then each and then children here. So yeah this is the package Laravel fluent validation. I will link that in the description below. Again the read me is huge and you can read it for yourself. Will you use it? Do you have any use cases for something like that? Or do you have any other workarounds or different packages that could achieve the same behavior? Let's discuss as usual in the comments below. That's it for this time and see you guys in other
More from Laravel Daily
Get daily recaps from
Laravel Daily
AI-powered summaries delivered to your inbox. Save hours every week while staying fully informed.









