42 lines
841 B
PHP
42 lines
841 B
PHP
<?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'],
|
|
];
|
|
}
|