2022-06-23 10:31:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace app\api\validate;
|
|
|
|
|
|
|
|
use think\Validate;
|
|
|
|
|
|
|
|
class Account extends Validate
|
|
|
|
{
|
|
|
|
protected $failException = true;
|
|
|
|
|
|
|
|
protected $rule = [
|
2022-12-14 15:32:42 +00:00
|
|
|
'username' => 'require|regex:^[a-zA-Z][a-zA-Z0-9_]{2,15}$|unique:user',
|
2022-06-23 10:31:31 +00:00
|
|
|
'nickname' => 'require|chsDash',
|
|
|
|
'birthday' => 'date',
|
|
|
|
'email' => 'require|email|unique:user',
|
|
|
|
'mobile' => 'require|mobile|unique:user',
|
2022-10-17 18:57:55 +00:00
|
|
|
'password' => 'require|regex:^(?!.*[&<>"\'\n\r]).{6,32}$',
|
2022-06-27 09:41:21 +00:00
|
|
|
'account' => 'require',
|
|
|
|
'captcha' => 'require',
|
2022-06-23 10:31:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 验证场景
|
|
|
|
*/
|
|
|
|
protected $scene = [
|
2023-08-31 05:27:20 +00:00
|
|
|
'edit' => ['username', 'nickname', 'birthday'],
|
2022-06-27 09:41:21 +00:00
|
|
|
'changePassword' => ['password'],
|
|
|
|
'retrievePassword' => ['account', 'captcha', 'password'],
|
2022-06-23 10:31:31 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->field = [
|
2022-12-14 15:32:42 +00:00
|
|
|
'username' => __('username'),
|
2022-06-23 10:31:31 +00:00
|
|
|
'nickname' => __('nickname'),
|
|
|
|
'birthday' => __('birthday'),
|
|
|
|
'email' => __('email'),
|
|
|
|
'mobile' => __('mobile'),
|
|
|
|
'password' => __('password'),
|
|
|
|
];
|
|
|
|
$this->message = array_merge($this->message, [
|
|
|
|
'nickname.chsDash' => __('nicknameChsDash'),
|
|
|
|
'password.regex' => __('Please input correct password')
|
|
|
|
]);
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
}
|