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

54 lines
1.2 KiB

<?php
declare (strict_types=1);
namespace app\api\validate;
use think\Validate;
class Config extends Validate
{
/**
* 定义验证规则
* 格式:'字段名' => ['规则1','规则2'...]
*
* @var array
*/
protected $rule = [
'id' => 'number|length:1,10',
'name|配置名称' => "require|uniqueSite:bmz_config|length:1,30",
'value|配置内容' => 'require|length:1,200',
'type|配置类型' => 'require|length:1,30',
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [
'name.require' => '请输入配置名称',
'name.length' => '配置名称必需在1~30位之间',
];
/**
* 验证场景规则
* @var array
*/
protected $scene = [
'read' => ['id'],
];
/**
* 自定义查询场景验证 可灵活设置验证字段
* @return Manager
*/
public function sceneLists()
{
return $this->only(['name', 'value', 'type'])
->remove('name', 'uniqueSite|require|length')
->remove('value', 'length|require')
->remove('type', 'length|require');
}
}