123456789101112131415161718192021222324252627282930313233343536373839 |
- <?php
- namespace app\api\validate;
- use think\Validate;
- class Cart extends Validate
- {
- /**
- * 验证规则
- */
- protected $rule = [
- 'goods_id' => 'require|integer|gt:0',
- 'goods_sku_id' => 'integer|egt:0',
- 'nums' => 'require|integer|gt:0',
- ];
- /**
- * 提示消息
- */
- protected $message = [
- 'goods_id.require' => '商品ID不能为空',
- 'goods_id.integer' => '商品ID必须是整数',
- 'goods_id.gt' => '商品ID必须大于0',
- 'goods_sku_id.integer' => '商品规格ID必须是整数',
- 'goods_sku_id.egt' => '商品规格ID必须大于或等于0',
- 'nums.require' => '商品数量不能为空',
- 'nums.integer' => '商品数量必须是整数',
- 'nums.gt' => '商品数量必须大于0',
- ];
- /**
- * 验证场景
- */
- protected $scene = [
- 'add' => ['goods_id', 'goods_sku_id', 'nums'],
- 'set_nums' => ['nums'],
- ];
- }
|