'^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]+$', 'password' => '/^(?![0-9]+$)(?![a-z]+$)(?![A-Z]+$)(?!([^(0-9a-zA-Z)]|[\(\)])+$)([^(0-9a-zA-Z)]|[\(\)]|[a-z]|[A-Z]|[0-9]){6,20}$/' ]; protected $rule = [ 'mobile' => 'require|mobile|unique:' . User::class, 'password' => 'require|length:6,20|regex:password', 'password_confirm' => 'require|confirm' ]; protected $message = [ 'mobile.require' => '请输入手机号', 'mobile.mobile' => '手机号格式错误', 'mobile.unique' => '手机号已存在', 'password.require' => '请输入密码', 'password.length' => '密码须在6-25位之间', 'password.regex' => '密码须为数字,字母或符号组合', '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; } }