38 lines
921 B
PHP
38 lines
921 B
PHP
<?php
|
|
namespace app\api\validate;
|
|
|
|
use think\Validate;
|
|
|
|
class Attribute extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'id' => ['require','integer','gt:0'],
|
|
'site_id|所属站点' => ['require','integer','gt:0'],
|
|
'page' => ['integer','gt:0'],
|
|
'size' => ['integer','gt:0'],
|
|
'name|属性名称' => ['length:1,50','require','unique:attribute,name^site_id^platform_id'],
|
|
];
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [];
|
|
|
|
protected $scene = [
|
|
'index' => [''],
|
|
'create' => ['name','site_id'],
|
|
'read' => ['id'],
|
|
'update' => ['id','name'],
|
|
'del' => ['id'],
|
|
];
|
|
}
|