52 lines
1.9 KiB
PHP
52 lines
1.9 KiB
PHP
<?php
|
|
namespace app\api\validate;
|
|
|
|
use think\Validate;
|
|
|
|
class Platform extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'id' => ['require','integer','gt:0'],
|
|
'page' => ['integer','gt:0'],
|
|
'size' => ['integer','gt:0'],
|
|
'sort|排序' => ['require','between:1,255'],
|
|
'name|品牌名称' => ['length:1,50','require','unique:platform,name'],
|
|
'status|状态' => ['in:0,1','integer'],
|
|
'vi_color1|品牌VI色标准色' => ['length:1,10','require','different:vi_color2','different:vi_color3','regex:^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$'],
|
|
'vi_color2|品牌VI色辅助色-深' => ['length:1,10','require','different:vi_color3','different:vi_color1','regex:^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$'],
|
|
'vi_color3|品牌VI色辅助色-浅' => ['length:1,10','require','different:vi_color1','different:vi_color2','regex:^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$'],
|
|
'currency_id|默认币种' => ['integer','gt:0'],
|
|
'language_id|默认语言' => ['integer','gt:0'],
|
|
'icon|品牌logo' => ['length:1,128'],
|
|
|
|
];
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [];
|
|
|
|
/**
|
|
* 验证场景定义
|
|
* @var array
|
|
*/
|
|
protected $scene = [
|
|
'index' => ['page','size'],
|
|
'read' => ['id'],
|
|
'create' => ['name','vi_color1','vi_color2','vi_color3','language_id','currency_id','desc','icon','status'],
|
|
'update' => ['id','vi_color1','vi_color2','vi_color3','language_id','currency_id','desc','icon','status'],
|
|
'del' => ['id'],
|
|
'upload' => [''],
|
|
'langeuageList' => ['']
|
|
];
|
|
}
|