智慧教务系统 PHP-NiuCloud框架开发
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

50 lines
1.6 KiB

<?php
// +----------------------------------------------------------------------
// | Niucloud-admin 企业快速开发的多应用管理平台
// +----------------------------------------------------------------------
// | 官方网址:https://www.niucloud.com
// +----------------------------------------------------------------------
// | niucloud团队 版权所有 开源版本可自由商用
// +----------------------------------------------------------------------
// | Author: Niucloud Team
// +----------------------------------------------------------------------
namespace app\validate\addon;
use app\dict\addon\AddonDict;
use think\facade\Route;
use think\Validate;
/**
* 开发插件
*/
class AddonDevelop extends Validate
{
protected $rule = [
'key' => 'require|regex:/^[a-zA-Z][a-zA-Z0-9_]{0,19}$/|keyBlacklist',
'type' => 'require|checkType',
];
protected $message = [
'key.require' => 'validate_addon.key_require',
'key.regex' => 'validate_addon.key_regex',
'key:in' => 'validate_addon.key_regex',
'type.require' => 'validate_addon.type_require',
];
protected $scene = [
"add" => ['key', 'type'],
"edit" => ['type']
];
protected function checkType($value, $rule, $data = [])
{
return (!empty($value) && isset(AddonDict::getType()[$value])) ? true : get_lang("validate_addon.not_exit_type");
}
public function keyBlacklist($value, $rule, $data = []) {
return in_array($value, AddonDict::ADDON_KEY_BLACK_LIST) ? get_lang("validate_addon.in_black_list") : true;
}
}