// +---------------------------------------------------------------------- declare(strict_types=1); namespace crmeb\basic; use think\Validate; /** * 验证器基类 * 所有验证器继承此类 * Class BaseValidate * @package crmeb\basic */ abstract class BaseValidate extends Validate { /** * 场景 * @var array */ protected $scene = []; /** * 验证数据 * @param array $data * @param string|null $scene * @return array|bool * @throws \think\exception\ValidateException */ public function goCheck(array $data, ?string $scene = null) { if ($scene) { $this->scene($scene); } $result = $this->check($data); if (!$result) { throw new \think\exception\ValidateException($this->getError()); } return $data; } }