From 3983c413f6380418b8ab89d26da5a2aa6ad6fbc3 Mon Sep 17 00:00:00 2001 From: wuyanwen Date: Tue, 14 Jan 2020 18:31:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=AA=8C=E8=AF=81=E4=B8=BA?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/CatchAdminService.php | 7 +++---- config/catch.php | 4 ++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/catch/CatchAdminService.php b/catch/CatchAdminService.php index 89c3624..510e11b 100644 --- a/catch/CatchAdminService.php +++ b/catch/CatchAdminService.php @@ -62,12 +62,11 @@ class CatchAdminService extends Service */ protected function registerValidates(): void { - $validates = [ - new Sometimes(), - ]; + Validate::maker(function($validate) { + $validates = config('catch.validates'); - Validate::maker(function($validate) use ($validates){ foreach ($validates as $vali) { + $vali = app()->make($vali); $validate->extend($vali->type(), [$vali, 'verify'], $vali->message()); } }); diff --git a/config/catch.php b/config/catch.php index 248776b..4a99092 100644 --- a/config/catch.php +++ b/config/catch.php @@ -33,4 +33,8 @@ return [ ], ], ], + + 'validates' => [ + \catcher\validates\Sometimes::class, + ], ];