L

Laravel Fluent Validation

Fluent and extremely fast validation for Laravel

Packages Free Open Source

About Laravel Fluent Validation

Write Laravel validation rules with IDE autocompletion instead of memorizing string syntax. Each rule type exposes only the methods that apply to it: FluentRule::string() won't offer digits(), FluentRule::date() won't offer mimes(). each() and children() keep parent and child rules in one place instead of scattered across dot-notation keys. For large arrays, the HasFluentRules trait makes wildcard validation up to 160x faster.

1// Before 
2'name' => 'required|string|min:2|max:255', 
3'email' => ['required', 'email', Rule::unique('users')->ignore($id)], 
4'role' => Rule::when($isAdmin, 'required|string|in:admin,editor'), 
5'items' => 'array', 'items.*.id' => 'required|integer|exists:items,id', 'items.*.name' => 'required|string|max:255', 
6 
7// After 
8'name' => FluentRule::string('Full Name')->required()->min(2)->max(255), 
9'email' => FluentRule::email('Email')->required()->unique('users', 'email', fn ($r) => $r->ignore($id)), 
10'role' => FluentRule::string()->when($isAdmin, fn ($r) => $r->required()->in(['admin', 'editor'])), 
11'items' => FluentRule::array()->each([ 'id' => FluentRule::integer()->required()->exists('items', 'id'), 'name' => FluentRule::string()->required()->max(255), ]),

Tags

laravel Laravel Validation

Reviews

No reviews yet. Be the first to review Laravel Fluent Validation!

Write a Review

Sign in to leave a review.

Stay Updated

Subscribe to our newsletter

Get latest news, tutorials, community articles and podcast episodes delivered to your inbox.

Weekly articles
We send a new issue of the newsletter every week on Friday.
No spam
We'll never share your email address and you can opt out at any time.