BaseValidate.php 602 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace app\common\validate;
  3. use app\exception\BaseException;
  4. use think\Request;
  5. use \think\validate;
  6. class BaseValidate extends Validate
  7. {
  8. /**
  9. * @param Request $request
  10. * @return bool
  11. * @throws BaseException TODO: 全局验证处理 前台传过来的值必须通过HttpRequestCheck方法进行验证
  12. */
  13. public function requestBodyCheck(Request $request): array
  14. {
  15. $params = $request->param();
  16. if (!$this->check($params)) {
  17. throw new BaseException($this->message = $this->getError());
  18. }
  19. return $params;
  20. }
  21. }