修改验证为配置注入

This commit is contained in:
wuyanwen 2020-01-14 18:31:08 +08:00
parent 2acf23d296
commit 3983c413f6
2 changed files with 7 additions and 4 deletions

View File

@ -62,12 +62,11 @@ class CatchAdminService extends Service
*/ */
protected function registerValidates(): void protected function registerValidates(): void
{ {
$validates = [ Validate::maker(function($validate) {
new Sometimes(), $validates = config('catch.validates');
];
Validate::maker(function($validate) use ($validates){
foreach ($validates as $vali) { foreach ($validates as $vali) {
$vali = app()->make($vali);
$validate->extend($vali->type(), [$vali, 'verify'], $vali->message()); $validate->extend($vali->type(), [$vali, 'verify'], $vali->message());
} }
}); });

View File

@ -33,4 +33,8 @@ return [
], ],
], ],
], ],
'validates' => [
\catcher\validates\Sometimes::class,
],
]; ];