47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
namespace app\api\validate;
|
|
|
|
use think\Validate;
|
|
|
|
class Currency extends Validate
|
|
{
|
|
/**
|
|
* 定义验证规则
|
|
* 格式:'字段名' => ['规则1','规则2'...]
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $rule = [
|
|
'id' => ['require','integer'],
|
|
'page' => ['integer','gt:0'],
|
|
'size' => ['integer','gt:0'],
|
|
'name|币种名称' => ['length:1,10','require','unique:currency,name'],
|
|
'code|币种缩写' => ['length:1,10','require','unique:currency,code'],
|
|
'signal|币种符号' => ['length:1,10','require'],
|
|
'status|状态' => ['in:0,1','integer'],
|
|
];
|
|
|
|
|
|
/**
|
|
* 定义错误信息
|
|
* 格式:'字段名.规则名' => '错误信息'
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $message = [];
|
|
|
|
|
|
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $scene = [
|
|
'index' => ['page','size'],
|
|
'read' => ['id'],
|
|
'create' => ['name','code','signal','status'],
|
|
'update' => ['id','name','code','signal','status'],
|
|
'del' => ['id'],
|
|
'changeStatus'=> ['id','status'],
|
|
];
|
|
}
|