| 1234567891011121314151617181920212223242526272829 |
- <?php
- namespace app\common\validate;
- use app\exception\BaseException;
- use think\Request;
- use \think\validate;
- class BaseValidate extends Validate
- {
- /**
- * @param Request $request
- * @return bool
- * @throws BaseException TODO: 全局验证处理 前台传过来的值必须通过HttpRequestCheck方法进行验证
- */
- public function requestBodyCheck(Request $request): array
- {
- $params = $request->param();
- if (!$this->check($params)) {
- throw new BaseException($this->message = $this->getError());
- }
- return $params;
- }
- }
|