{"id":15643061,"url":"https://github.com/timacdonald/pulse-validation-errors","last_synced_at":"2025-04-06T03:09:56.440Z","repository":{"id":239144636,"uuid":"798667138","full_name":"timacdonald/pulse-validation-errors","owner":"timacdonald","description":"Validation errors card for Laravel Pulse","archived":false,"fork":false,"pushed_at":"2024-06-26T22:33:59.000Z","size":325,"stargazers_count":94,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-30T08:18:23.608Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/timacdonald.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-10T08:35:26.000Z","updated_at":"2024-10-02T13:04:35.000Z","dependencies_parsed_at":"2024-05-28T05:39:54.308Z","dependency_job_id":"3767cd7b-ac21-48df-9f47-85a74842660f","html_url":"https://github.com/timacdonald/pulse-validation-errors","commit_stats":{"total_commits":30,"total_committers":6,"mean_commits":5.0,"dds":"0.30000000000000004","last_synced_commit":"ef9883e99d27c1e749a62431c46e34f225534aec"},"previous_names":["timacdonald/pulse-validation-errors"],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timacdonald%2Fpulse-validation-errors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timacdonald%2Fpulse-validation-errors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timacdonald%2Fpulse-validation-errors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timacdonald%2Fpulse-validation-errors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timacdonald","download_url":"https://codeload.github.com/timacdonald/pulse-validation-errors/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247427006,"owners_count":20937201,"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":[],"created_at":"2024-10-03T11:58:46.434Z","updated_at":"2025-04-06T03:09:56.421Z","avatar_url":"https://github.com/timacdonald.png","language":"PHP","funding_links":[],"categories":["Cards"],"sub_categories":["Application"],"readme":"# Validation errors card for Laravel Pulse\n\nA card for Laravel Pulse to show validation errors impacting users.\n\n\u003cp align=\"center\"\u003e\u003cimg src=\"https://raw.githubusercontent.com/timacdonald/pulse-validation-errors/main/art/screenshot.png\" alt=\"Validation errors card for Laravel Pulse\"\u003e\u003c/p\u003e\n\n## Installation\n\nFirst, install the package via composer:\n\n```sh\ncomposer require timacdonald/pulse-validation-errors\n```\n\nNext, add the recorder to your `config/pulse.php`:\n\n```php\n\nreturn [\n    // ...\n\n    'recorders' =\u003e [\n        TiMacDonald\\Pulse\\Recorders\\ValidationErrors::class =\u003e [\n            'enabled' =\u003e env('PULSE_VALIDATION_ERRORS_ENABLED', true),\n            'sample_rate' =\u003e env('PULSE_VALIDATION_ERRORS_SAMPLE_RATE', 1),\n            'capture_messages' =\u003e true,\n            'ignore' =\u003e [\n                // '#^/login$#',\n                // '#^/register$#',\n                // '#^/forgot-password$#',\n            ],\n            'groups' =\u003e [\n                // '#^/products/.*$#' =\u003e '/products/{user}',\n            ],\n        ],\n\n        // ...\n    ],\n];\n```\n\nNext, add the card to your `resources/views/vendor/pulse/dashboard.php`:\n\n```blade\n\u003cx-pulse\u003e\n    \u003clivewire:pulse.validation-errors cols=\"8\" rows=\"4\" /\u003e\n\n    \u003c!-- ... --\u003e\n\u003c/x-pulse\u003e\n```\n\nFinally, get to improving your user experience. At LaraconUS I gave a [talk on how much our validation sucks](https://youtu.be/MMc2TzBY6l4?si=UEu8dLuRK4XT30yK). If you are here, you likely also care about how your users experience validation errors on your app, so I'd love you to give it a watch.\n\n\n## Features\n\n- Supports session based validation errors\n- Supports API validation errors\n- Support Inertia validation errors\n- Support Livewire validation errors\n- Supports multiple error bags\n- Fallback for undetectable validation errors (based on 422 response status)\n- Capture generic validation exceptions for custom response types\n\n## Ignore specific error messages\n\nYou may ignore specific endpoints via the recorders `ignore` key, however in some situations you may need more complex ignore rules. You can use [Pulse's built in `Pulse::filter` method](https://laravel.com/docs/11.x/pulse#filtering) to achieve this.\n\nHere is an example where we are ignore a specific error message:\n\n```php\nuse Laravel\\Pulse\\Entry;\nuse Laravel\\Pulse\\Facades\\Pulse;\nuse Laravel\\Pulse\\Value;\n\n/**\n * Bootstrap any application services.\n */\npublic function boot(): void\n{\n    Pulse::filter(fn ($entry): bool =\u003e match ($entry-\u003etype) {\n        'validation_error' =\u003e ! Str::contains($entry-\u003ekey, [\n            'The password is incorrect.',\n            'Your password has appeared in a data leak.',\n            // ...\n        ]),\n        // ...\n        default =\u003e true,\n    });\n}\n```\n\n## Capture validation errors for custom response formats\n\nIf you are returning custom response formats, you may see `__laravel_unknown` in the dashboard instead of the input names and error messages. This is because the package parses the response body to determine the validation errors. When the body is in an unrecognised format it is unable to parse the keys and messages from the response.\n\nYou should instead dispatch the `ValidationExceptionOccurred` event to pass the validation messages to the card's recorder. You may do this wherever you are converting your exceptions into responses. This usually happens in the `app/Exceptions/Handler`:\n\n```php\n\u003c?php\n\nnamespace App\\Exceptions\\Handler;\n\nuse Illuminate\\Support\\Facades\\Event;\nuse Illuminate\\Validation\\ValidationException;\nuse Laravel\\Pulse\\Facades\\Pulse;\nuse Throwable;\nuse TiMacDonald\\Pulse\\ValidationExceptionOccurred\n\nclass Handler\n{\n    // ...\n\n    public function render($request, Throwable $e)\n    {\n        if ($e instanceof ValidationException) {\n            Pulse::rescue(fn () =\u003e Event::dispatch(new ValidationExceptionOccurred($request, $e)));\n        }\n\n        // custom exception rendering logic...\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimacdonald%2Fpulse-validation-errors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimacdonald%2Fpulse-validation-errors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimacdonald%2Fpulse-validation-errors/lists"}