Validate an Inertia form with a form request

Move Inertia form rules into a form request and pass validated() to the model. authorize() still runs.

For your AI agent

Copies a prompt. Paste it into the AI agent you already have open.

Read https://laravel-vuejs.space/laravel-form-request-inertia.md
Move Inertia form rules into a form request and pass validated() to the model. authorize() still runs.
Do not return true from authorize() on a request that updates someone else's post.
Show the diff. Do not commit.
On this page · 3 sections
  1. The fix
  2. What to avoid
  3. FAQ

People searching “Laravel form request Inertia” want the rules off the controller. The Vue page does not change. It still posts title and reads form.errors.title, as in the CRUD guide.

TL;DR

  • Move Inertia form rules into a form request and pass validated() to the model.
  • authorize() still runs.
  • Do not return true from authorize() on a request that updates someone else’s post.

Who it's for: Laravel + Vue developers on Inertia

Applies to: Laravel 13 · Inertia 3 · Vue 3

The fix#

shell
php artisan make:request StorePostRequest
php
public function authorize(): bool
{
    return $this->user() !== null;
}

public function rules(): array
{
    return [
        'title' => ['required', 'string', 'max:120'],
    ];
}
php
public function store(StorePostRequest $request): RedirectResponse
{
    Post::create([
        'title' => $request->validated('title'),
        'user_id' => $request->user()->id,
    ]);

    return to_route('posts.index');
}

$request->validated() is the only array you should persist. A key that is not in rules() is dropped, which is the point.

What to avoid#

Gotcha

Do not return true from authorize() on a request that updates someone else’s post. That method is a gate. The owner check belongs in a policy, and authorize() can call it.

FAQ#

How do I validate an Inertia form with a form request?

Move Inertia form rules into a form request and pass validated() to the model. authorize() still runs.

What goes wrong with Laravel form request Inertia?

Many developers want the rules off the controller. Do not return true from authorize() on a request that updates someone else's post.

Found this useful?

Ask questions, share what you built.

Join thousands of Laravel and Vue developers in our Facebook group, or get new posts in your Telegram feed. Sharing this article helps too.

Keep reading

Newsletter

Get the best of Laravel & Vue, once a month.

One short email with new guides, release notes worth reading and hand-picked community links. No spam, unsubscribe any time.