创建模型验证器,验证数据正确性
This commit is contained in:
23
app/common/validate/GameConfig.php
Normal file
23
app/common/validate/GameConfig.php
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\common\validate;
|
||||
|
||||
use think\Validate;
|
||||
|
||||
class GameConfig extends Validate
|
||||
{
|
||||
protected $failException = true;
|
||||
|
||||
protected $rule = [
|
||||
'config_key' => 'require|max:64|unique:game_config',
|
||||
'value_type' => 'require|in:string,int,decimal,json',
|
||||
'remark' => 'max:255',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['config_key', 'value_type', 'remark'],
|
||||
'edit' => ['value_type', 'remark'],
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user