johnvict / error-format
Error-Format helps you do validation and returns a more pleasing error object if there is one or more, using Laravel In-built Validator
Installs: 44
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/johnvict/error-format
Requires
- php: ^7.2
- illuminate/support: ^7.28.4
This package is auto-updated.
Last update: 2025-10-16 02:29:09 UTC
README
Error Format is used to format error on laravel/lumen framework. It restructures the error object to a simpler-to-use error object
Installation
Use composer to install Error Format.
composer require johnvict/error-format
Usage
namespace App\Http\Controllers; use Illuminate\Http\Request; use Johnvict\ErrorFormat\Services\ErrorFormat; class ExampleController extends Controller { /** * Add the ErrorFormat trait to your controller to enable the use of validate request as part of the controller class */ use ErrorFormat; public function home(Request $request) { // You can define an array of your validation rule $errorRule = [ "name" => "required|string", "phone" => "required|string", "username" => "required|string", "email" => "email" ]; // call the validateRequest as follows $error = self::validateRequest($request, $errorRule); return response()->json($error); } }
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.