init: 项目初始代码
This commit is contained in:
41
app/api/validate/Role.php
Normal file
41
app/api/validate/Role.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 角色
|
||||
* Class Role
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class Role extends Validate
|
||||
{
|
||||
/**
|
||||
* 定义验证规则
|
||||
* 格式:'字段名' => ['规则1','规则2'...]
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $rule = [
|
||||
'id' => ['require','integer','gt:0'],
|
||||
'page' => ['integer','gt:0'],
|
||||
'size' => ['integer','gt:0'],
|
||||
'name' => ['length:1,50','require'],
|
||||
];
|
||||
|
||||
/**
|
||||
* 定义错误信息
|
||||
* 格式:'字段名.规则名' => '错误信息'
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [];
|
||||
|
||||
protected $scene = [
|
||||
'index' => ['page','size'],
|
||||
'read' => ['id'],
|
||||
'create' => ['name'],
|
||||
'update' => ['id','name'],
|
||||
'del' => ['id'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user