Enforce request validation style rules
linter / quality (pull_request) Successful in 2m28s
tests / ci (8.4) (pull_request) Successful in 1m22s

This commit is contained in:
2026-04-11 19:44:21 +02:00
parent 97b188e942
commit 73cee8178f
7 changed files with 101 additions and 72 deletions
@@ -0,0 +1,28 @@
---
name: project-request-validation-style
description: "Always apply in this project when changing Laravel controllers or FormRequest classes. Enforces dedicated FormRequest usage for controller validation, validated-array access via Arr::get(), and forbids custom single-field getter methods or request helper extraction like boolean()/integer()/string() for app input handling."
---
# Project Request Validation Style
## When to Apply
Activate this skill whenever work in this project changes:
- Laravel controllers
- Laravel FormRequest classes
- Validation flow between controllers and requests
## Rules
- Do not add inline controller validation with `$request->validate(...)` when the endpoint has request-specific validation needs.
- Prefer dedicated `FormRequest` classes and use `$validated = $request->validated();` in controllers.
- When reading validated arrays, use `Arr::get($validated, 'key')` instead of direct array access.
- Do not use request helper extraction like `$request->boolean()`, `$request->integer()`, `$request->string()`, or similar helpers for application input handling.
- Do not add custom FormRequest getter helpers such as `points()`, `branchName()`, `ticketAttributes()`, or similar single-purpose accessors.
- Build controller payloads from the validated array directly with `Arr::get(...)`.
## Notes
- `Arr::get(...)` already returns `null` by default, so do not wrap it in redundant existence checks when `null` is acceptable.
- Keep validation logic in the FormRequest and payload shaping in the controller or dedicated action.