Request
DevelopmentrequestRequest is an Agent Skill for development published in the JaguarJack/catch-admin repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Generate form request validation for CatchAdmin module.
QUICK START
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/JaguarJack/catch-admin/blob/HEAD/.claude/skills/05-request/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/request, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Step 5: Generate Request Validation
创建表单验证类。
File Location
modules/{Module}/Http/Requests/{Model}Request.php
Template
<?php
namespace Modules\{Module}\Http\Requests;
use Illuminate\Foundation\Http\FormRequest;
class {Model}Request extends FormRequest
{
public function authorize(): bool
{
return true;
}
public function rules(): array
{
return [
// Generated from field definitions
];
}
public function messages(): array
{
return [
// Custom messages
];
}
}
Validation Rules Mapping
| Field Type | Validation Rule |
|---|---|
| string(n), required | 'required|string|max:n' |
| string(n), nullable | 'nullable|string|max:n' |
| integer | 'sometimes|integer|min:0' |
| decimal | 'required|numeric|min:0' |
| tinyint (status) | 'sometimes|integer|in:1,2' |
| foreign_key | 'required|integer|exists:table,id' |
| text | 'nullable|string' |
'required|email|max:100' | |
| date | 'nullable|date' |
Unique Validation
对于更新操作,需要排除当前记录:
public function rules(): array
{
$id = $this->route('id');
return [
'email' => "required|email|unique:{table},email,{$id}",
];
}