Search by

sandermuller / laravel-fluent-validation-rector

SanderMuller

Rector rules for migrating Laravel validation to sandermuller/laravel-fluent-validation

Package info

github.com/SanderMuller/laravel-fluent-validation-rector

Homepage

Type:rector-extension

pkg:composer/sandermuller/laravel-fluent-validation-rector

Statistics

Installs: 22 380

Dependents: 0

Suggesters: 0

Stars: 5

Open Issues: 2

1.11.1 2026-07-16 19:35 UTC

README

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.