域名管理
This commit is contained in:
Executable
+39
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace app\admin\validate;
|
||||
|
||||
use app\admin\model\Domain as DomainModel;
|
||||
use think\Validate;
|
||||
|
||||
/**
|
||||
* 域名验证器
|
||||
*/
|
||||
class Domain extends Validate
|
||||
{
|
||||
protected $rule = [
|
||||
'domain' => 'require|checkDomain',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'domain.require' => '请输入根域名',
|
||||
];
|
||||
|
||||
protected $scene = [
|
||||
'add' => ['domain'],
|
||||
];
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function checkDomain($value)
|
||||
{
|
||||
$domain = DomainModel::normalizeDomain((string)$value);
|
||||
if (!DomainModel::isValidRootDomain($domain)) {
|
||||
return '请输入合法根域名,不要填写 www 或二级子域名,且不支持中国域名后缀';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user