Files
CompanyProject/金壶/ydyd_service/application/common/validate/goods/GoodsValidate.php
2024-09-27 01:32:49 +08:00

41 lines
952 B
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
namespace app\common\validate\goods;
use app\common\validate\BaseValidate;
class GoodsValidate extends BaseValidate
{
/**
* 定义验证规则
* 格式:'字段名' => ['规则1','规则2'...]
*
* @var array
*/
protected $rule = [
'goods_name|商品名称'=>'require',
'goods_id|商品id'=>'require|number',
'spu_id|'=>'require|number',
'sku_id|商品sku_id'=>'require|integer',
];
/**
* 定义错误信息
* 格式:'字段名.规则名' => '错误信息'
*
* @var array
*/
protected $message = [];
/**
* 定义验证场景
* @var array ['场景名称1'=>[验证字段1验证字段2…],…]
* 场景名称建议命名规范控制器名_方法名
*/
protected $scene = [
'goods_detail'=>['sku_id'],
'goods_search'=>[null],//[null]或[''];[]校验全部$rule定义的字段
];
}