DEV Community

Cover image for Laravel Validation Rule Builder: Generate Form Requests Fast
devTalk
devTalk

Posted on Originally published at dev-talk.com

Laravel Validation Rule Builder: Generate Form Requests Fast

Last updated: 27 November 2026. Verified against the tool's own page atdev-talk.com/tools/laravel-validation-rule-builder; seeHow this was checked.

Writing validation rules for a new endpoint is usually the most tedious part of adding one. You already know the column types from the migration — you're just translating them into required, max:255, exists:users,id and so on by hand, and it's easy to get one wrong in a way that only shows up when a bad request slips through. The Laravel Validation Rule Builder is a free, browser-based tool that does that translation for you, either from scratch or by importing something you already have.

What it does

The tool runs entirely client-side — it needs JavaScript, requires no sign-up, and the page states plainly that nothing is uploaded; input is processed locally in your browser. You define each field for a table or request, pick a type (email, price, image upload, foreign-key ID, and more), adjust its rules, and the tool assembles the final Laravel 12 validation code. If you'd rather not start from a blank slate, you can import an existing migration, a SHOW CREATE TABLE dump, a phpMyAdmin export, or a rules() method you already have, and let the tool reconstruct the field definitions from that.

Setting up fields and rules

For each field you set a name — including nested array names like items.*.quantity — a type, and whether it's required. From there you attach rules using searchable rule chips: the reference covers 97 rules across categories like presence, conditional rules, type, text, size and numbers, dates, lists, other-field comparisons, files, database rules, and rule objects, and each one has an "Add" button that applies it to whichever field is currently selected.

You choose whether the generated rules render as array syntax (['required', 'max:255']) or as pipe strings ('required|max:255'); the builder automatically switches to array syntax when a rule needs it — rule objects and regex patterns containing a pipe character can't safely be expressed as a pipe string, so it won't let you paint yourself into that corner. There's also a "for update" option, which swaps a plain unique rule for Rule::unique(...)->ignore(...) so editing a record doesn't trip over its own existing value, and a messages toggle that generates a matching messages() method for custom error text alongside the rules.

Importing from something you already have

This is the part that saves the most time if you're retrofitting validation onto an existing table. The importer recognizes common migration patterns and translates them directly:

  • string('name', 100) becomes string plus max:100
  • foreignId()->constrained() becomes exists:users,id
  • a column with a unique() index gets the unique rule
  • an enum column gets an in:... rule listing its allowed values
  • decimal(8,2) maps to decimal:0,2
  • any NOT NULL column with no default becomes required

When you import on top of an existing set of fields, you can choose to replace the current fields entirely or add the imported ones alongside what's already there — useful if you're merging a new migration into a request you're already building out.

Output formats

Once your fields and rules are set, you pick how you want the final code shaped: a Form Request class (the default), an inline $request->validate() call, a standalone Validator::make() call, or a Livewire component. You can copy the result directly or download it as a .php file to drop into app/Http/Requests or straight into a controller method.

Things worth knowing before you paste the output in

  • nullableonly permits an actualnullvalue. An empty form field typically arrives as an empty string or gets normalized to null depending on your front end, and an unchecked checkbox simply won't be present in the request at all — nullable doesn't give you a free pass on the rest of a field's rules if what arrives isn't the type those rules expect.
  • Pipe strings and arrays validate identically — the difference is purely which rules force your hand. Rule objects and any regex containing a literal | require array syntax, and the tool switches to it automatically when you add a rule that needs it.
  • A couple of rules carry a real per-request cost. active_url performs a DNS lookup on every validation run, and email:rfc,dns does the same for checking the domain's mail records. Neither is free, so don't sprinkle them onto high-traffic forms without thinking about the added latency.
  • The tool's own page states that the Form Requests generated for its built-in examples were loaded and tested against Laravel 12, and that every rule name in its reference was checked against Laravel's validator — worth knowing if you're wondering whether a less common rule name is spelled correctly before you commit to it.

update log

  • 27 November 2026: first version.
  • To recheck next time: whether the rule reference is updated for Laravel 13-specific validation additions, and whether new output formats or import sources are added.

Frequently asked questions

Does the tool send my database schema or migration to a server?

No — the page states that nothing is uploaded and that input is processed locally in your browser using JavaScript. That makes it reasonable to paste in schema details without worrying about your table structure leaving your machine.

Can it generate validation for updating an existing record, not just creating one?

Yes, via the "for update" option, which changes a plain unique rule into Rule::unique(...)->ignore(...) so the record being edited doesn't fail validation against its own current value.

What if my table already has a migration — do I have to re-enter every field by hand?

No, that's exactly what the import feature is for. Paste in the migration (or just its $table-> lines), a SHOW CREATE TABLE statement, or a phpMyAdmin export, and the tool reconstructs field types and reasonable default rules from it, which you can then adjust by hand.

Does it only output Form Request classes?

Form Request is the default output, but you can also generate an inline $request->validate() call, a standalone Validator::make() call, or a Livewire component, depending on where the validation needs to live in your app.

Related Dev Talk articles


Originally published on DEV Talk.

Top comments (0)