You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

68 lines
1.6 KiB

<?php
declare (strict_types=1);
namespace app\api\validate;
use think\facade\Db;
use think\Validate;
class Menu extends Validate
{
/**
* 定义验证规则
* 格式:'字段名' => ['规则1','规则2'...]
*
* @var array
*/
protected $rule = [
'id' => 'number|length:1,10',
'name|菜单名称' => "require|uniqueSite:system_auth_rule|length:1,15",
'path|路由地址' => 'length:1,100',
'model_name|接口地址' => 'require|length:1,100',
'component|组件路径' => 'length:1,100',
'authority|权限标识' => 'uniqueSite:system_auth_rule|length:1,100',
'icon|图标' => 'length:1,100',
'hide|显示隐藏' => 'max:1|min:0',
'sort|排序' => 'between:0,10000',
'menu_type|菜单类型' => 'max:1|min:0',
'remarks|菜单备注' => 'length:1,100',
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [
'username.require' => '请输入菜单名称',
'username.length' => '菜单名称必需在1~15位之间',
];
/**
* 验证场景规则
* @var array
*/
protected $scene = [
'read' => ['id'],
];
/**
* 修改场景验证
* @return Manager
*/
public function sceneUpdate()
{
}
/**
* 自定义查询场景验证 可灵活设置验证字段
* @return Manager
*/
public function sceneLists()
{
return $this->remove('name', 'require|uniqueSite')
->remove('model_name', 'require');
}
}