sandermuller/laravel-fluent-validation
Type-safe, IDE-autocomplete Laravel validation rule builders. Create rules fluently without memorizing strings; each rule exposes only valid methods. Define nested array validation with each()/children(). Optional HasFluentRules trait speeds wildcard validation dramatically (up to 160x).
'name|required|string|min:2') with a type-safe, IDE-autocomplete-driven alternative.min:5 on a string vs. integer) via static typing and method chaining.items.*.id).attributes()/messages() arrays).orders.*.line_items.*.price).role requires permissions only if isAdmin).when(), requiredIf(), etc.FluentRule::email()->required()->unique('users')).✅ Validation logic is complex (nested arrays, dynamic conditions, bulk operations).
✅ Team struggles with string-based validation syntax (e.g., min:5 ambiguity, unique:table,column,id order).
✅ Performance is critical for large payloads (e.g., >100 items in items.*.*).
✅ IDE support is a priority (autocompletion for ->required()->min(5)->max(255)).
✅ Type safety is desired (PHPStan integration flags unbounded each() chains).
❌ Project uses Laravel <11 or PHP <8.2 (package requires these).
❌ Validation is trivial (e.g., simple forms with 3–5 fields).
❌ Team prefers string syntax for brevity (though fluent syntax is often more readable).
❌ No budget for migration (Rector automates ~80% of refactoring, but manual tweaks may be needed).
❌ Using Filament/Livewire without HasFluentValidation trait (requires workaround).
"Reduce validation bugs and speed up bulk operations by 160x."
'name|required|string') leads to errors (e.g., wrong min: units, misplaced unique clauses) and slows down imports/bulk edits.FluentRule::string()->min(5)->max(255)).min: rules or debugging unique syntax.attributes()/messages() arrays)."Validation that’s faster, safer, and easier to write."
FluentRule::email()->required()->unique('users') vs. 'email|required|email|unique:users'.->min() only for strings, ->afterToday() only for dates).items.*.*)—160x faster than Laravel’s native validation.each() chains; Rector migrates legacy code automatically.rules()/messages() arrays).HasFluentRules trait to new Form Requests."Fewer validation bugs in production."
->digits() on a string).FluentRule::string('Full Name') ensure messages use correct field names.items.*.id definitions).'items.*.id' => 'required|integer|exists:items,id',
'items.*.name' => 'required|string|max:255',
After:
'items' => FluentRule::array()->each([
'id' => FluentRule::integer()->required()->exists('items', 'id'),
'name' => FluentRule::string()->required()->max(255),
]),
Result: Easier to audit, less chance of missing a rule.How can I help you explore Laravel packages today?