{"id":34600969,"url":"https://github.com/wangchristine/form-request","last_synced_at":"2026-06-01T09:31:12.944Z","repository":{"id":62501663,"uuid":"422805362","full_name":"wangchristine/form-request","owner":"wangchristine","description":"This package can use form request just as Laravel do.","archived":false,"fork":false,"pushed_at":"2021-11-17T16:01:39.000Z","size":11,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-23T06:10:18.453Z","etag":null,"topics":["form-request","lumen","validation"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/wangchristine.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-10-30T06:42:25.000Z","updated_at":"2021-11-17T16:00:37.000Z","dependencies_parsed_at":"2022-11-02T12:01:47.529Z","dependency_job_id":null,"html_url":"https://github.com/wangchristine/form-request","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/wangchristine/form-request","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangchristine%2Fform-request","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangchristine%2Fform-request/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangchristine%2Fform-request/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangchristine%2Fform-request/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wangchristine","download_url":"https://codeload.github.com/wangchristine/form-request/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wangchristine%2Fform-request/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33769490,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-01T02:00:06.963Z","response_time":115,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["form-request","lumen","validation"],"created_at":"2025-12-24T12:45:22.352Z","updated_at":"2026-06-01T09:31:12.937Z","avatar_url":"https://github.com/wangchristine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lumen Form Request\n\n\u003e This package can use form request just as Laravel do.\n\n# Installation\n\nInstall by composer\n\n```bash\n    $ composer require chhw/form-request\n```\n\nIn `bootstrap/app.php`, you should:\n1. uncomment `$app-\u003ewithFacades();`\n2. add `$app-\u003eregister(CHHW\\FormRequest\\FormRequestServiceProvider::class);`\n\n# Usage\n\n\u003e Just like the way to use Laravel !\n\n### By structured file:\n\nadd something request like: `app/Http/Requests/CreatePost.php`，extends `CHHW\\FormRequest\\FormRequest`\n\n\u003e app/Http/Requests/CreatePost.php\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Requests;\n\nuse CHHW\\FormRequest\\FormRequest;\n\nclass CreatePost extends FormRequest\n{\n    /**\n     * Determine if the user is authorized to make this request.\n     *\n     * @return bool\n     */\n    public function authorize()\n    {\n        return true;\n    }\n\n    /**\n     * Get the validation rules that apply to the request.\n     *\n     * @return array\n     */\n    public function rules()\n    {\n        return [\n            \"title\" =\u003e \"required|string\",\n        ];\n    }\n\n    public function withValidator($validator)\n    {\n        $validator-\u003eafter(function ($validator) {\n             if (true) {\n                 $validator-\u003eerrors()-\u003eadd('field', 'Something is wrong with this field!');\n             }\n        });\n    }\n}\n\n```\n\n\u003e app/Http/Controllers/ExampleController.php:\n\n```php\nuse App\\Http\\Requests\\CreatePost;\n\nclass ExampleController extends Controller\n{\n    public function test(CreatePost $request)\n    {\n        dd($request-\u003eall());\n        // ...\n    }\n}\n```\n\n### Or in controller:\n\n\u003e app/Http/Controllers/ExampleController.php\n\n```php\nuse App\\Rules\\Uppercase;\nuse Illuminate\\Http\\Request;\n\nclass ExampleController extends Controller\n{\n    public function create(Request $request)\n    {\n        $request-\u003evalidate([\"author\" =\u003e [\"required\", new Uppercase],]);\n        // ...\n    }\n}\n```\n\n\u003e app/Rules/Uppercase.php\n\n```php\n \u003c?php\n\nnamespace App\\Rules;\n\nuse Illuminate\\Contracts\\Validation\\Rule;\n\nclass Uppercase implements Rule\n{\n    /**\n     * Determine if the validation rule passes.\n     *\n     * @param  string  $attribute\n     * @param  mixed  $value\n     * @return bool\n     */\n    public function passes($attribute, $value)\n    {\n        return strtoupper($value) === $value;\n    }\n\n    /**\n     * Get the validation error message.\n     *\n     * @return string\n     */\n    public function message()\n    {\n        return 'The :attribute must be uppercase.';\n    }\n}\n```\n\n### Get Request and Rule file by command:\n```bash\nphp artisan make:request CreatePost\nphp artisan make:rule Uppercase\n```\n\n# Customize Localization Error Messages\n\n\u003e just like laravel !\n\nadd `resources/lang/en/validation.php`, and other country languages.\n\n# Error handler\n\n\u003e app/Exceptions/Handler.php\n\n```php\npublic function render($request, Throwable $exception)\n{\n    if($exception instanceof ValidationException){\n        return response()-\u003ejson([\"message\" =\u003e $exception-\u003egetMessage(), \"details\" =\u003e $exception-\u003eerrors()]);\n    }\n    return parent::render($request, $exception);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangchristine%2Fform-request","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwangchristine%2Fform-request","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwangchristine%2Fform-request/lists"}