65 lines
1.5 KiB
PHP
65 lines
1.5 KiB
PHP
<?php
|
|
declare (strict_types = 1);
|
|
|
|
namespace app\admin\validate\v1;
|
|
|
|
use think\Validate;
|
|
|
|
class VideoCategoryValidate extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'id' => 'require|integer',
|
|
'language_id' => 'require|integer',
|
|
'name' => 'require|max:64',
|
|
'sort' => 'integer',
|
|
'is_show' => 'in:0,1',
|
|
];
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [
|
|
'id.require' => 'ID不能为空',
|
|
'id.integer' => 'ID必须是整数',
|
|
'language_id.require' => '语言ID不能为空',
|
|
'language_id.integer' => '语言ID必须是整数',
|
|
'name.require' => '名称不能为空',
|
|
'name.max' => '名称不能超过64个字符',
|
|
'sort.integer' => '排序必须是整数',
|
|
'is_show.in' => '是否显示必须是0或1',
|
|
];
|
|
|
|
/**
|
|
* 新增场景
|
|
*/
|
|
public function sceneCreate()
|
|
{
|
|
return $this->remove('id', 'require|integer');
|
|
}
|
|
|
|
/**
|
|
* 更新场景
|
|
*/
|
|
public function sceneUpdate()
|
|
{
|
|
return $this->remove('language_id', 'require|integer');
|
|
}
|
|
|
|
/**
|
|
* 设置排序值场景
|
|
*/
|
|
public function sceneSort()
|
|
{
|
|
return $this->only(['sort']);
|
|
}
|
|
}
|