diff --git a/app/Providers/AppServiceProvider.php b/app/Providers/AppServiceProvider.php index e3bcb5d..89e43a4 100644 --- a/app/Providers/AppServiceProvider.php +++ b/app/Providers/AppServiceProvider.php @@ -27,6 +27,16 @@ public function register(): void $this->app->bind(CardRepositoryInterface::class, CardRepository::class); $this->app->bind(TransactionRepositoryInterface::class, TransactionRepository::class); $this->app->bind(TransactionCostRepositoryInterface::class, TransactionCostRepository::class); + $this->renderable(function (ValidationException $e, $request) { + if ($request->expectsJson()) { + return response()->json([ + 'success' => false, + 'message' => __('errors.validation_failed'), + 'errors' => $e->errors(), + 'code' => 422 + ], 422); + } + }); } /**