Looking to hire Laravel developers? Try LaraJobs

laravel-fluent-validation-rector maintained by sandermuller

Description
Rector rules for migrating Laravel validation to sandermuller/laravel-fluent-validation
Author
Last update
2026/08/30 10:52 (dev-main)
License
Downloads
20 201

Comments
comments powered by Disqus

Laravel Fluent Validation Rector

Latest Version on Packagist GitHub Tests Action Status GitHub PHPStan Action Status Total Downloads License

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.

Installation

composer require --dev sandermuller/laravel-fluent-validation-rector

Requires PHP 8.3+, Rector 2.5+, and sandermuller/laravel-fluent-validation ^1.32.0. On an older fluent-validation, see the pin table.

Getting started

// 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                       # format

ALL runs converters, grouping and trait insertion. Three sets stay out of it on purpose and run as later passes: SIMPLIFY, POLISH, and SCHEMA.

Documentation

Full documentation lives at https://sandermuller.github.io/laravel-fluent-validation-rector/.

The sources are in docs/; the frozen public surface is in PUBLIC_API.md.

Testing

composer test          # vendor/bin/pest
composer qa            # format → rector → phpstan → test

The suite runs against Orchestra Testbench, so no host Laravel app is required.

Changelog

Release notes live in CHANGELOG.md and on the releases page.

Contributing

See CONTRIBUTING.md for the dev setup, test workflow, and PR conventions.

Security

Disclose vulnerabilities privately. See SECURITY.md.

Credits

License

MIT. See LICENSE.md.