Initial commit: ThinkPHP refactor (tp)
Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
declare (strict_types = 1);
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 用户验证器
|
||||
*/
|
||||
class User extends Validate
|
||||
{
|
||||
/**
|
||||
* 验证规则
|
||||
*/
|
||||
protected $rule = [
|
||||
'username' => 'require|length:3,20|chsDash',
|
||||
'password' => 'require|length:6,20',
|
||||
'email' => 'require|email',
|
||||
'phone' => 'mobile',
|
||||
'nickname' => 'length:2,20',
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证提示信息
|
||||
*/
|
||||
protected $message = [
|
||||
'username.require' => '用户名不能为空',
|
||||
'username.length' => '用户名长度3-20位',
|
||||
'username.chsDash' => '用户名只能是汉字、字母、数字和下划线_及破折号-',
|
||||
'password.require' => '密码不能为空',
|
||||
'password.length' => '密码长度6-20位',
|
||||
'email.require' => '邮箱不能为空',
|
||||
'email.email' => '邮箱格式不正确',
|
||||
'phone.mobile' => '手机号格式不正确',
|
||||
'nickname.length' => '昵称长度2-20位',
|
||||
];
|
||||
|
||||
/**
|
||||
* 验证场景
|
||||
*/
|
||||
protected $scene = [
|
||||
'login' => ['username', 'password'],
|
||||
'register' => ['username', 'password', 'email'],
|
||||
'update' => ['email', 'phone', 'nickname'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user