Files

50 lines
1.4 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;
/**
* Role 类
*
* @author ywxapp <admin@ywxapp.cn>
*/
class Role extends Validate
{
protected $rule = [
'name' => 'require|min:2|max:50',
'code' => 'require|min:2|max:50|alphaDash',
'description' => 'max:255',
'status' => 'require|in:0,1',
];
protected $message = [
'name.require' => '角色名称不能为空',
'name.min' => '角色名称长度不能少于2个字符',
'name.max' => '角色名称长度不能超过50个字符',
'code.require' => '角色编码不能为空',
'code.min' => '角色编码长度不能少于2个字符',
'code.max' => '角色编码长度不能超过50个字符',
'code.alphaDash' => '角色编码只能包含字母、数字、下划线和破折号',
'description.max' => '角色描述长度不能超过255个字符',
'status.require' => '状态不能为空',
'status.in' => '状态值不正确',
];
// 更新场景
public function sceneUpdate()
{
return $this->append('id', 'require|number');
}
}