laravel:form-requests

Form Requests and Validation

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "laravel:form-requests" with this command: npx skills add jpcaparas/superpowers-laravel/jpcaparas-superpowers-laravel-laravel-form-requests

Form Requests and Validation

Promote validation and authorization to dedicated Form Request classes. Keep controllers focused on orchestration and domain intents.

Commands

Create a request

sail artisan make:request UpdateProfileRequest # or: php artisan make:request UpdateProfileRequest

Use in controller method signature

public function update(UpdateProfileRequest $request) { $data = $request->validated(); // ... }

Patterns

  • Define authorize() to gate access; prefer Policies for complex checks

  • Use rule objects: Rule::unique('users', 'email')->ignore($user->id)

  • Validate nested arrays: items.*.sku , addresses.home.city

  • Prefer nullable

  • specific rules instead of sometimes for optional fields
  • Standardize attribute names / messages via attributes() and messages()

  • Centralize common rules in custom Rule classes or traits

  • Return $request->safe()->only([...]) when partial updates are intended

Testing

  • Feature test the endpoint: assert validation errors and success flows

  • Unit test custom validators and rule objects in isolation

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

laravel:routes-best-practices

No summary provided by upstream source.

Repository SourceNeeds Review
General

laravel:blade-components-and-layouts

No summary provided by upstream source.

Repository SourceNeeds Review
General

laravel:queues-and-horizon

No summary provided by upstream source.

Repository SourceNeeds Review
General

laravel:quality-checks

No summary provided by upstream source.

Repository SourceNeeds Review