123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\api\validate;
- use think\Validate;
- class Goods extends Validate
- {
- /**
- * 验证规则
- */
- protected $rule = [
- 'orderby' => 'in:weigh,sales,price,views,comments,created_at',
- 'orderway' => 'in:asc,desc',
- 'pageSize' => 'integer|between:1,100',
- 'page' => 'integer|between:1,100',
- 'keywords' => 'string|max:255',
- 'category_id' => 'integer',
- 'brand_id' => 'integer',
- ];
- /**
- * 提示消息
- */
- protected $message = [
- 'orderby.in' => '排序字段只能是权重、销量、价格、浏览数或评论数',
- 'orderway.in' => '排序方式只能是升序或降序',
- 'pageSize.integer' => '页码必须是整数',
- 'pageSize.between' => '页码必须在1到100之间',
- 'page.integer' => '页码必须是整数',
- 'page.between' => '页码必须在1到100之间',
- 'keywords.string' => '关键词必须是字符串',
- 'keywords.max' => '关键词长度不能超过255个字符',
- 'category_id.integer' => '分类ID必须是整数',
- 'brand_id.integer' => '品牌ID必须是整数',
- ];
- /**
- * 验证场景
- */
- protected $scene = [
- 'lists' => ['orderby', 'orderway', 'pageSize', 'page', 'keywords', 'category_id', 'brand_id'],
- 'getCategoryGoods' => ['category_id','page', 'pageSize'],
- ];
- }
|