51 lines
1.6 KiB
PHP
51 lines
1.6 KiB
PHP
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | YwxApp [ WE CAN DO IT JUST THINK ]
|
|
// +----------------------------------------------------------------------
|
|
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
|
|
// +----------------------------------------------------------------------
|
|
// | Author: ywxapp<admin@ywxapp.cn>
|
|
// +----------------------------------------------------------------------
|
|
declare (strict_types = 1);
|
|
|
|
namespace addon\wxchat\validate;
|
|
|
|
use think\Validate;
|
|
|
|
/**
|
|
* Member 类
|
|
*
|
|
* @author ywxapp <admin@ywxapp.cn>
|
|
*/
|
|
class Member extends Validate
|
|
{
|
|
// 创建用户验证规则
|
|
protected $rule = [
|
|
'temp_token' => 'require',
|
|
'nickname' => 'require|max:20',
|
|
'gender' => 'in:0,1,2', // 0:未知 1:男 2:女
|
|
'birthday' => 'date',
|
|
'invite_code' => 'max:20',
|
|
'avatar' => 'max:500',
|
|
];
|
|
|
|
// 创建用户验证消息
|
|
protected $message = [
|
|
'temp_token.require' => '临时令牌不能为空',
|
|
'nickname.require' => '昵称不能为空',
|
|
'nickname.max' => '昵称最多20个字符',
|
|
'gender.in' => '性别参数错误',
|
|
'birthday.date' => '生日格式错误',
|
|
'invite_code.max' => '邀请码最多20个字符',
|
|
'avatar.max' => '头像地址过长',
|
|
];
|
|
|
|
// 创建用户场景
|
|
|
|
public function sceneCreate()
|
|
{
|
|
return $this->only(['temp_token', 'nickname', 'gender', 'birthday', 'invite_code', 'avatar'])
|
|
->remove('nickname', 'require'); // 允许昵称为空,会自动生成
|
|
}
|
|
}
|