BaseValidate.php 593 B

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