Skip to content

Fluent ValidationLaravel validation rules your IDE understands

Typed, chainable rule builders with co-located array rules, labels and messages attached to the rule itself, and wildcard validation up to 160x faster.

Laravel Fluent Validation

From strings to fluent

php
// Before
'name'         => 'required|string|min:2|max:255',
'email'        => ['required', 'email', Rule::unique('users')->ignore($id)],
'items'        => 'array',
'items.*.id'   => 'required|integer|exists:items,id',
'items.*.name' => 'required|string|max:255',

// After
'name'  => FluentRule::string('Full Name')->required()->min(2)->max(255),
'email' => FluentRule::email('Email')->required()->unique('users', 'email', fn ($r) => $r->ignore($id)),
'items' => FluentRule::array()->each([
    'id'   => FluentRule::integer()->required()->exists('items', 'id'),
    'name' => FluentRule::string()->required()->max(255),
]),

Install with Composer and add one trait to your form request. Existing string rules keep working while you migrate field by field.

bash
composer require sandermuller/laravel-fluent-validation

Where to next