'^(?=.*[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 = [ 'phone' => 'require|mobile|unique:user', 'code' => 'require|checkCode', 'password' => 'require|length:6,20', 'age' => 'number|gt:0', 'gender' => 'in:0,1,2', 'realname' => 'chs|length:2,25', 'id_card' => 'idCard', 'province' => 'number', 'city' => 'number', 'area' => 'number', 'street' => 'number', 'village' => 'number', 'brigade' => 'number', ]; protected $message = [ 'phone.require' => '请输入手机号码', 'phone.mobile' => '请输入正确的手机号码', 'phone.unique' => '该手机号码已注册', 'code.require' => '请输入验证码', 'password.require' => '请输入密码', 'password.length' => '密码须在6-25位之间', 'age.number' => '年龄必须是数字', 'age.gt' => '年龄必须大于0', 'gender.in' => '用户性别值错误', 'realname.chs' => '真实姓名必须是汉字', 'realname.length' => '真实姓名长度必须大于2个汉字且不得超过25个汉字', 'id_card.idCard' => '身份证号码不正确', 'province.number' => '省份编码值错误', 'city.number' => '城市编码值错误', 'area.number' => '区县编码值错误', 'street.number' => '镇街编码值错误', 'village.number' => '村社编码值错误', 'brigade.number' => '小组编码值错误', ]; public function checkCode($code, $rule, $data): bool|string { $smsDriver = new SmsDriver(); $result = $smsDriver->verify($data['phone'], $code, NoticeEnum::REGISTER_CAPTCHA); if ($result) { return true; } return '验证码错误'; } }