<?php namespace App\Http\Validators\Admin; use App\Http\Validators\AbstractValidator; class TestValidator extends AbstractValidator { /** * Validation rules * * @var Array */ protected $rules = array( 'name' => ['required', 'test', 'min:1'], ); /** * Validation messages * * @var Array */ protected $messages = array( 'name.required' => '必填', 'name.min' => '最少1个字符', 'name.test' => '测试', ); /** * 自定义验证规则或者扩展Validator类 */ public function before() { $this->extend('test', function ($attribute, $value, $parameters) { return bool; }); } }
路由中如何使用
Route::post('https://www.jb51.net/', ['middleware' => ['valiAdmin:Test'], 'uses' => 'IndexController@test']);
具体使用可以自行配置~