bradietilley/laravel-rules is a Laravel package for fluent rules for form requests in laravel.
It currently has 8 GitHub stars and 15 downloads on Packagist (latest version v1.4.0).
Install it with composer require bradietilley/laravel-rules.
Discover more Laravel packages by bradietilley
or browse all Laravel packages to compare alternatives.
Last updated
Fluent, chainable validation rules for Laravel.
Full documentation is available at bradietilley.dev/laravel-rules.
composer require bradietilley/laravel-rules
use BradieTilley\Rules\Rule;
use Illuminate\Validation\Rules\Password;
return [
'email' => Rule::make()
->bail()
->when(
$this->method() === 'POST',
Rule::make()->required(),
Rule::make()->sometimes(),
)
->string()
->email()
->unique(
table: User::class,
column: 'email',
ignore: $this->route('user')?->id,
),
'password' => rule()
->bail()
->when(
$this->method() === 'POST',
rule()->required(),
rule()->sometimes(),
)
->string()
->password(
Password::min(8)->letters()->numbers(),
),
];
See the documentation for usage, customisation, and the optional ValidationRule helper.