refactor: 修改产品校验规则

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

View File

@@ -14,6 +14,7 @@ class ProductValidate extends Validate
* @var array * @var array
*/ */
protected $rule = [ protected $rule = [
'language_id' => 'require|integer',
'category_id' => 'integer', 'category_id' => 'integer',
'spu' => 'require|max:255', 'spu' => 'require|max:255',
'name' => 'require|max:125', 'name' => 'require|max:125',
@@ -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',