Rector rules for migrating Laravel validation to sandermuller/laravel-fluent-validation. Pipe-delimited strings, array-based rules, Rule:: objects, and Livewire #[Rule] attributes all convert to FluentRule method chains.
// Before
return [
'email' => 'required|email|max:255',
'tags' => ['nullable', 'array'],
'tags.*' => 'string|max:50',
];
// After
return [
'email' => FluentRule::email()->required()->max(255),
'tags' => FluentRule::array()->nullable()->each(
FluentRule::string()->max(50),
),
];Tested on a production codebase: 448 files converted, 3,469 tests still passing.
composer require --dev sandermuller/laravel-fluent-validation-rectorRequires PHP 8.3+, Rector 2.5+, and sandermuller/laravel-fluent-validation ^1.32.0. On an older fluent-validation, see the pin table.
// rector.php
use Rector\Config\RectorConfig;
use SanderMuller\FluentValidationRector\Set\FluentValidationSetList;
return RectorConfig::configure()
->withPaths([__DIR__ . '/app'])
->withSets([FluentValidationSetList::ALL]);vendor/bin/rector process --dry-run # preview
vendor/bin/rector process # apply
vendor/bin/pint # formatALL runs converters, grouping and trait insertion. Three sets stay out of it on purpose and run as later passes: SIMPLIFY, POLISH, and SCHEMA.
Full documentation lives at https://sandermuller.github.io/laravel-fluent-validation-rector/.
- Why this package? · Installation · Getting started · Sets
- String and array converters · Livewire attributes · Wildcard grouping · Trait insertion
- Simplify · Docblock polish · Adopting FluentSchema
- The
#[FluentRules]attribute · Configuration - Formatter integration · Diagnostics · Parity harness · AI assistant integration
- Rule reference · Detection and limitations
The sources are in docs/; the frozen public surface is in PUBLIC_API.md.
composer test # vendor/bin/pest
composer qa # format → rector → phpstan → testThe suite runs against Orchestra Testbench, so no host Laravel app is required.
Release notes live in CHANGELOG.md and on the releases page.
See CONTRIBUTING.md for the dev setup, test workflow, and PR conventions.
Disclose vulnerabilities privately. See SECURITY.md.
MIT. See LICENSE.md.