PHP code example of timacdonald / pulse-validation-errors
1. Go to this page and download the library: Download timacdonald/pulse-validation-errors library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
timacdonald / pulse-validation-errors example snippets
use Laravel\Pulse\Entry;
use Laravel\Pulse\Facades\Pulse;
use Laravel\Pulse\Value;
/**
* Bootstrap any application services.
*/
public function boot(): void
{
Pulse::filter(fn ($entry): bool => match ($entry->type) {
'validation_error' => ! Str::contains($entry->key, [
'The password is incorrect.',
'Your password has appeared in a data leak.',
// ...
]),
// ...
default => true,
});
}
namespace App\Exceptions\Handler;
use Illuminate\Support\Facades\Event;
use Illuminate\Validation\ValidationException;
use Laravel\Pulse\Facades\Pulse;
use Throwable;
use TiMacDonald\Pulse\ValidationExceptionOccurred
class Handler
{
// ...
public function render($request, Throwable $e)
{
if ($e instanceof ValidationException) {
Pulse::rescue(fn () => Event::dispatch(new ValidationExceptionOccurred($request, $e)));
}
// custom exception rendering logic...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.