1.5 KiB
1.5 KiB
name, description
| name | description |
|---|---|
| project-request-validation-style | 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
FormRequestclasses 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 returnsnullby default, so do not wrap it in redundant existence checks whennullis acceptable.- Keep validation logic in the FormRequest and payload shaping in the controller or dedicated action.