Skip to content
Back to skills

Form Requests And Validation

ASecurity

Move validation and authorization into Form Requests; use rule objects, custom messages, and nested data handling to keep controllers slim

  • 147 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added June 6, 2026
testingphptesting

Security analysis

A100/100

Scanned June 6, 2026

npx -y skills add jpcaparas/superpowers-laravel --skill form-requests-and-validation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Form Requests And Validation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Form Requests And Validation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/jpcaparas-form-requests-and-validation/badge)](https://www.skillsdirectory.com/skills/jpcaparas-form-requests-and-validation)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: laravel:form-requests
description: Move validation and authorization into Form Requests; use rule objects, custom messages, and nested data handling to keep controllers slim
---

# 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

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.