refactor: 修改产品校验规则

This commit is contained in:
2025-02-11 10:18:48 +08:00
parent 29105d0096
commit ae8802987a

View File

@@ -14,24 +14,25 @@ class ProductValidate extends Validate
* @var array * @var array
*/ */
protected $rule = [ protected $rule = [
'category_id' => 'integer', 'language_id' => 'require|integer',
'spu' => 'require|max:255', 'category_id' => 'integer',
'name' => 'require|max:125', 'spu' => 'require|max:255',
'short_name' => 'max:64', 'name' => 'require|max:125',
'cover_image' => 'max:255', 'short_name' => 'max:64',
'desc' => 'max:255', 'cover_image' => 'max:255',
'video_img' => 'max:255', 'desc' => 'max:255',
'video_url' => 'max:255', 'video_img' => 'max:255',
'is_sale' => 'in:0,1', 'video_url' => 'max:255',
'is_new' => 'in:0,1', 'is_sale' => 'in:0,1',
'is_hot' => 'in:0,1', 'is_new' => 'in:0,1',
'sort' => 'integer', 'is_hot' => 'in:0,1',
'detail' => 'max:65535', 'sort' => 'integer',
'status' => 'in:-1,1', 'detail' => 'max:65535',
'seo_title' => 'max:255', 'status' => 'in:-1,1',
'seo_title' => 'max:255',
'seo_keywords' => 'max:255', 'seo_keywords' => 'max:255',
'seo_desc' => 'max:255', 'seo_desc' => 'max:255',
'created_at' => 'checkFormatDatetimeRange' 'created_at' => 'checkFormatDatetimeRange'
]; ];
/** /**
@@ -41,6 +42,8 @@ class ProductValidate extends Validate
* @var array * @var array
*/ */
protected $message = [ protected $message = [
'language_id.require' => '语言ID不能为空',
'language_id.integer' => '语言ID必须为整数',
'category_id.integer' => '分类ID必须为整数', 'category_id.integer' => '分类ID必须为整数',
'spu.require' => 'spu不能为空', 'spu.require' => 'spu不能为空',
'spu.max' => 'spu不能超过255个字符', 'spu.max' => 'spu不能超过255个字符',
@@ -77,6 +80,7 @@ class ProductValidate extends Validate
public function sceneUpdate() public function sceneUpdate()
{ {
return $this->only([ return $this->only([
'language_id',
'category_id', 'category_id',
'spu', 'spu',
'name', 'name',