All checks were successful
Gitea Actions Official-website / deploy-dev (push) Successful in 3s
74 lines
2.6 KiB
PHP
74 lines
2.6 KiB
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\admin\validate\v1;
|
|
|
|
use think\Validate;
|
|
|
|
class ProductCompatValidate extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'language_id' => 'require|integer',
|
|
'type_id' => 'require|integer',
|
|
'part_id' => 'require|integer',
|
|
'model' => 'require|max:128',
|
|
'brand_name' => 'require|max:128',
|
|
'level_name' => 'max:128',
|
|
'spec_name' => 'max:128',
|
|
'series_name' => 'max:128',
|
|
'capacity' => 'max:32',
|
|
'frequency' => 'max:128',
|
|
'compatible_models' => 'require|max:512',
|
|
'sort' => 'integer',
|
|
'disabled' => 'in:0,1'
|
|
];
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [
|
|
'id.require' => 'ID不能为空',
|
|
'id.integer' => 'ID必须为整数',
|
|
'language_id.require' => '语言ID必须',
|
|
'language_id.integer' => '语言ID必须为整数',
|
|
'type_id.require' => '类型ID必须',
|
|
'type_id.integer' => '类型ID必须为整数',
|
|
'part_id.require' => '配件ID必须',
|
|
'part_id.integer' => '配件ID必须为整数',
|
|
'model.require' => '型号必须',
|
|
'model.max' => '型号不能超过:rule个字符',
|
|
'brand_name.require' => '品牌必须',
|
|
'brand_name.max' => '品牌不能超过:rule个字符',
|
|
'level_name.max' => '等级不能超过:rule个字符',
|
|
'spec_name.max' => '规格不能超过:rule个字符',
|
|
'series_name.max' => '系列不能超过:rule个字符',
|
|
'capacity.max' => '容量不能超过:rule个字符',
|
|
'frequency.max' => '接口类型不能超过:rule个字符',
|
|
'compatible_models.v' => '兼容型号必须',
|
|
'compatible_models.max' => '兼容型号不能超过:rule个字符',
|
|
'sort.integer' => '排序必须为整数',
|
|
'disabled.in' => '禁用状态必须为0或1',
|
|
];
|
|
|
|
// 新增场景
|
|
protected function sceneAdd()
|
|
{
|
|
return $this->remove("id", "require|integer");
|
|
}
|
|
|
|
// 编辑场景
|
|
protected function sceneEdit()
|
|
{
|
|
return $this->append("id", "require|integer");
|
|
}
|
|
}
|