捕梦者基础框架API接口
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.
 
 

52 lines
1.3 KiB

<?php
declare (strict_types=1);
namespace app\api\validate;
use think\Validate;
class Group extends Validate
{
/**
* 定义验证规则
* 格式:'字段名' => ['规则1','规则2'...]
*
* @var array
*/
protected $rule = [
'id' => 'number|length:1,10',
'title|角色名称' => "require|uniqueSite:system_auth_group|length:2,20",
'role_code|角色标识' => "require|uniqueSite:system_auth_group|length:2,20",
'remark|角色备注' => 'length:2,200',
'status|状态' => 'number|length:1',
'page|页码' => 'number|length:1,10',
'pagesize|每页数量' => 'number|length:1,10',
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [
'title.require' => '请输入角色名称',
];
/**
* 验证场景规则
* @var array
*/
protected $scene = [
'read' => ['id'],
];
public function sceneLists()
{
return $this->remove('title', 'require|uniqueSite|length')
->append('title', 'min:1|max:20') //删除title length之后 ,再append length就无效了,只能换成min max
->remove('role_code','require|uniqueSite|length')
->append('role_code','min:1|max:20');
}
}