johnvict/error-format
Composer 安装命令:
composer require 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
README 文档
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.
License
统计信息
- 总下载量: 44
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-15