/syarif-laravel-ai-skills:form-requestsfrom syarif-laravel-ai-skills
Guides using Laravel Form Requests for validation and authorization, keeping controllers thin and testable. Covers input normalization, authorization, array rules, and testing.
Ships in syarif-laravel-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use Form Requests for HTTP validation and request-bound authorization when rules are complex, reused, sensitive, or likely to grow.
Inline controller validation is acceptable for tiny prototypes or legacy maintenance, but it is not the global standard for new or heavily edited workflows.
A Form Request may:
prepareForValidation();It should not:
Normalize human-formatted inputs before applying numeric/date/boolean rules. Keep locale assumptions explicit.
final class StoreRecordRequest extends FormRequest
{
protected function prepareForValidation(): void
{
$this->merge([
'amount' => NumberInput::normalize($this->input('amount')),
]);
}
public function rules(): array
{
return [
'amount' => ['required', 'numeric', 'min:0'],
'status' => ['required', Rule::enum(RecordStatus::class)],
];
}
}
Shared parsers should be small helpers or value objects with unit tests.
Use authorize() when the decision depends on request context or validated input. Use Policies when the decision depends on model state.
public function authorize(): bool
{
return $this->user()?->can('create', Record::class) === true;
}
Use the simplest Laravel-native validation rule set that fully matches the actual input shape and behavior. Reuse the existing Form Request structure when safe. Do not introduce complex nested rules, helper abstractions, or additional validation structures unless the behavior actually requires them.
Validate nested arrays explicitly.
public function rules(): array
{
return [
'items' => ['required', 'array', 'min:1'],
'items.*.name' => ['required', 'string', 'max:120'],
'items.*.quantity' => ['required', 'integer', 'min:1'],
];
}
Prefer named custom rule objects when validation has reusable domain meaning.
Test validation failures and authorization failures. Cover request normalization when human-formatted values are accepted.
Layer: 3 (Implementation)
Load this skill only when validation or request authorization is nontrivial. Inline tiny validation in controllers only for prototypes or legacy maintenance. Keep Form Requests focused: rules, authorize, prepareForValidation, no database writes or business workflows.
What SKILL.md sets; muted values are Claude Code's defaults
Generated from the plugin's indexed repository (soden46/syarif-laravel-ai-skills) — no native marketplace selected
npx claudepluginhub p/soden46-syarif-laravel-ai-skills72 skills in this plugin
/actions-and-servicesUse Actions and Services as deliberate Laravel application boundaries for use cases, integrations, and reusable workflows./ai-sdkBuild AI features with the first-party Laravel AI SDK (Laravel 13+); agents, embeddings, images, audio, and tool calling with provider-agnostic APIs/api-resources-and-paginationLaravel guidance to use API Resources with pagination and conditional fields; keep response shapes stable and cache-friendly