{"id":25817230,"url":"https://github.com/devlop/laravel-failed-validation-response","last_synced_at":"2026-05-19T04:33:25.112Z","repository":{"id":56966803,"uuid":"347018436","full_name":"devlop/laravel-failed-validation-response","owner":"devlop","description":"Trait for Laravel FormRequest to enable the use of custom responses for failed validation attempts.","archived":false,"fork":false,"pushed_at":"2024-01-12T05:47:09.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T19:21:09.437Z","etag":null,"topics":["form-request","laravel","php","trait","validation"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devlop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-03-12T09:55:37.000Z","updated_at":"2024-01-12T05:46:20.000Z","dependencies_parsed_at":"2024-01-14T13:06:09.501Z","dependency_job_id":null,"html_url":"https://github.com/devlop/laravel-failed-validation-response","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"87e0524903852f731ee354c662105f372d3f7033"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Flaravel-failed-validation-response","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Flaravel-failed-validation-response/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Flaravel-failed-validation-response/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Flaravel-failed-validation-response/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devlop","download_url":"https://codeload.github.com/devlop/laravel-failed-validation-response/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241090641,"owners_count":19907989,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","laravel","php","trait","validation"],"created_at":"2025-02-28T06:23:02.586Z","updated_at":"2026-05-19T04:33:20.092Z","avatar_url":"https://github.com/devlop.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/devlop/laravel-failed-validation-response\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/devlop/laravel-failed-validation-response\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/devlop/laravel-failed-validation-response/blob/master/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/devlop/laravel-failed-validation-response\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Laravel Failed Validation Response\n\nTrait for [Laravel FormRequests](https://laravel.com/docs/8.x/validation#form-request-validation)\nto enable the use of custom responses for failed validation (or authorization) attempts.\n\n# Installation\n\n```bash\ncomposer require devlop/laravel-failed-validation-response\n```\n\n# Usage\n\n```php\nuse Devlop\\Laravel\\Validation\\FailedValidationResponse;\nuse Illuminate\\Contracts\\Validation\\Validator;\nuse Illuminate\\Foundation\\Http\\FormRequest;\nuse Symfony\\Component\\HttpFoundation\\Response;\n\nclass DemoRequest extends FormRequest\n{\n    use FailedValidationResponse;\n\n    // ... Your normal FormRequest logic.\n\n    /**\n     * Get the response for a failed validation attempt.\n     *\n     * @param  Validator  $validator\n     * @return Response|null\n     */\n    public function failedValidationResponse(Validator $validator) : ?Response\n    {\n        // Implement this method to use a custom response on validation failure.\n        // Do not implement this method to instead use the default behaviour.\n\n        // Example:\n        return redirect()-\u003eto('/');\n    }\n\n    /**\n     * Get the response for a failed authorization attempt.\n     *\n     * @param  Validator  $validator\n     * @return Response|null\n     */\n    public function failedAuthorizationResponse(Validator $validator) : ?Response\n    {\n        // Implement this method to use a custom response on authorization failure.\n        // Do not implement this method to instead use the default behaviour.\n\n        // Example:\n        return response()-\u003ejson([\n            'reason' =\u003e 'you are not allowed to that!',\n        ], 401);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlop%2Flaravel-failed-validation-response","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevlop%2Flaravel-failed-validation-response","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlop%2Flaravel-failed-validation-response/lists"}