48 lines
1.1 KiB
PHP
48 lines
1.1 KiB
PHP
<?php
|
|
namespace app\api\validate;
|
|
|
|
use think\Validate;
|
|
|
|
/**
|
|
* 优惠
|
|
* Class GoodsCoupon
|
|
* @package app\api\validate
|
|
*/
|
|
class GoodsCoupon extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'id' => ['require','integer','gt:0'],
|
|
'page' => ['integer','gt:0'],
|
|
'size' => ['integer','gt:0'],
|
|
'site_id|语言包ID' => ['integer','gt:0'],
|
|
// 'old_code|旧口令' => ['length:1,30'],
|
|
'new_code|新口令' => ['require','length:1,30','unique:goods_coupon,new_code^old_code^id'],
|
|
];
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [];
|
|
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $scene = [
|
|
'index' => ['page','size'],
|
|
'read' => ['id'],
|
|
'create' => ['site_id','old_code','new_code'],
|
|
'update' => ['id','old_code','new_code'],
|
|
'del' => ['id'],
|
|
];
|
|
}
|