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 Module extends Validate
{
/**
* 定义验证规则
* 格式:'字段名' => ['规则1','规则2'...]
*
* @var array
*/
protected $rule = [
'id' => 'number|length:1,10',
'module_name|模块名称' => "require|length:1,100",
'table_name|表名称' => "require|length:1,50",
'model_name|模型名称' => "require|length:1,50",
'table_comment|表描述' => "require|length:1,50",
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [
'module_name.require' => '请输入模块名称',
'module_name.length' => '模块名称必需在1~100位之间',
'table_name.require' => '请输入表名称',
'table_name.length' => '表名称必需在1~100位之间',
'model_name.require' => '请输入模型名称',
'model_name.length' => '模型名称必需在1~100位之间',
'table_comment.require' => '请输入表描述',
'table_comment.length' => '表描述必需在1~100位之间',
];
/**
* 验证场景规则
* @var array
*/
protected $scene = [
'read' => ['id'],
];
/**
* 修改场景验证
* @return Manager
*/
public function sceneUpdate()
{
return $this->remove('module_name', 'require');
}
/**
* 自定义查询场景验证 可灵活设置验证字段
* @return Manager
*/
public function sceneLists()
{
}
}