58 lines
1.8 KiB
PHP
58 lines
1.8 KiB
PHP
<?php
|
|
/*
|
|
* @Author: YwxApp <ywx@ywxapp.cn>
|
|
* @Date: 2026-04-29 02:32:33
|
|
* @LastEditors: YwxApp <ywx@ywxapp.cn>
|
|
* @LastEditTime: 2026-07-21 23:27:10
|
|
* @Description:
|
|
* @FilePath: \ywxapp_dev\app\backend\validate\Admin.php
|
|
* @CustomString: Copyright (c) 2026 YwxApp
|
|
*/
|
|
|
|
declare (strict_types = 1);
|
|
namespace app\backend\validate;
|
|
|
|
use think\Validate;
|
|
|
|
/**
|
|
* User 类
|
|
*
|
|
* @author ywxapp <admin@ywxapp.cn>
|
|
*/
|
|
class User extends Validate
|
|
{
|
|
protected $rule = [
|
|
'username' => 'require|min:3|max:20',
|
|
'nickname' => 'require|min:2|max:20',
|
|
'password' => 'require|min:6|max:20',
|
|
'email' => 'require|email',
|
|
'phone' => 'require|mobile',
|
|
'status' => 'require|in:0,1',
|
|
'roleIds' => 'array',
|
|
];
|
|
|
|
protected $message = [
|
|
'username.require' => '用户名不能为空',
|
|
'username.min' => '用户名长度不能少于3个字符',
|
|
'username.max' => '用户名长度不能超过20个字符',
|
|
'nickname.require' => '昵称不能为空',
|
|
'nickname.min' => '昵称长度不能少于2个字符',
|
|
'nickname.max' => '昵称长度不能超过20个字符',
|
|
'password.require' => '密码不能为空',
|
|
'password.min' => '密码长度不能少于6个字符',
|
|
'password.max' => '密码长度不能超过20个字符',
|
|
'email.require' => '邮箱不能为空',
|
|
'email.email' => '邮箱格式不正确',
|
|
'phone.require' => '电话不能为空',
|
|
'phone.mobile' => '电话格式不正确',
|
|
'status.require' => '状态不能为空',
|
|
'status.in' => '状态值不正确',
|
|
];
|
|
|
|
// 更新场景
|
|
|
|
public function sceneUpdate()
|
|
{
|
|
return $this->remove('password', 'require');
|
|
}
|
|
} |