Files
orico-official-website/app/admin/validate/v1/VideoValidate.php

84 lines
2.5 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
declare (strict_types = 1);
namespace app\admin\validate\v1;
use think\Validate;
class VideoValidate extends Validate
{
/**
* 定义验证规则
* 格式:'字段名' => ['规则1','规则2'...]
*
* @var array
*/
protected $rule = [
'id' => 'require|integer',
'language_id' => 'require|integer',
'category_id' => 'require|integer',
'name' => 'require|max:64',
'desc' => 'max:255',
'image' => 'max:125',
'video' => 'max:125',
'link' => 'url|max:125',
'sort' => 'integer',
'recommend' => 'integer|in:1,0',
'seo_title' => 'max:255',
'seo_keywords' => 'max:255',
'seo_desc' => 'max:255',
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [
'id.require' => 'ID不能为空',
'id.integer' => 'ID参数类型错误',
'language_id.require' => '语言不能为空',
'language_id.integer' => '语言参数类型错误',
'category_id.require' => '分类不能为空',
'category_id.integer' => '分类参数类型错误',
'name.require' => '名称不能为空',
'name.max' => '名称不能超过64个字符',
'desc.max' => '描述不能超过255个字符',
'image.max' => '图片不能超过125个字符',
'video.max' => '视频不能超过125个字符',
'link.url' => '链接格式错误',
'link.max' => '链接不能超过125个字符',
'sort.integer' => '排序参数类型错误',
'recommend.integer' => '推荐参数类型错误',
'recommend.in' => '推荐参数错误必须是1或0',
'seo_title.max' => 'SEO标题不能超过255个字符',
'seo_keywords.max' => 'SEO关键字不能超过255个字符',
'seo_desc.max' => 'SEO描述不能超过255个字符',
];
/**
* 新增韬晦
*/
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']);
}
}