update #39

Merged
weiz merged 1 commits from zhangwei into dev 2023-12-07 10:00:27 +08:00
1 changed files with 28 additions and 0 deletions

View File

@ -16,6 +16,7 @@ namespace app\api\validate;
use app\common\enum\notice\NoticeEnum;
use app\common\model\user\User;
use app\common\service\JsonService;
use app\common\service\sms\SmsDriver;
use app\common\validate\BaseValidate;
@ -48,4 +49,31 @@ class RegisterValidate extends BaseValidate
'password_confirm.require' => '请确认密码',
'password_confirm.confirm' => '两次输入的密码不一致'
];
public function goCheck($scene = null, array $validateData = []): array
{
//接收参数
if ($this->method == 'GET') {
$params = request()->get();
} else {
$params = request()->post();
}
//合并验证参数
$params = array_merge($params, $validateData);
//场景
if ($scene) {
$result = $this->scene($scene)->check($params);
} else {
$result = $this->check($params);
}
if (!$result) {
$exception = is_array($this->error) ? implode(';', $this->error) : $this->error;
$data = $exception == '手机号已存在' ? ['has_register'=>1] : [];
JsonService::throw($exception,$data);
}
// 3.成功返回数据
return $params;
}
}