mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-19 14:54:00 +08:00
fix: 修改数据库名称校验
This commit is contained in:
parent
1787261727
commit
168ff2ded3
@ -80,6 +80,19 @@ const checkDomain = (rule: any, value: any, callback: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
const checkDatabaseName = (rule: any, value: any, callback: any) => {
|
||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
||||
callback(new Error(i18n.global.t('commons.rule.databaseName')));
|
||||
} else {
|
||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_]{0,30}$/;
|
||||
if (!reg.test(value) && value !== '') {
|
||||
callback(new Error(i18n.global.t('commons.rule.databaseName')));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
interface CommonRule {
|
||||
requiredInput: FormItemRule;
|
||||
requiredSelect: FormItemRule;
|
||||
@ -93,6 +106,7 @@ interface CommonRule {
|
||||
ip: FormItemRule;
|
||||
port: FormItemRule;
|
||||
domain: FormItemRule;
|
||||
databaseName: FormItemRule;
|
||||
}
|
||||
|
||||
export const Rules: CommonRule = {
|
||||
@ -129,6 +143,11 @@ export const Rules: CommonRule = {
|
||||
validator: checkLinuxName,
|
||||
trigger: 'blur',
|
||||
},
|
||||
databaseName: {
|
||||
required: true,
|
||||
validator: checkDatabaseName,
|
||||
trigger: 'blur',
|
||||
},
|
||||
password: {
|
||||
validator: complexityPassword,
|
||||
trigger: 'blur',
|
||||
|
@ -113,6 +113,7 @@ export default {
|
||||
port: '请输入正确的端口',
|
||||
selectHelper: '请选择正确的 {0} 文件',
|
||||
domain: '域名格式错误',
|
||||
databaseName: '支持英文、数字、_,长度1-30',
|
||||
},
|
||||
res: {
|
||||
paramError: '请求失败,请稍后重试!',
|
||||
|
@ -108,7 +108,7 @@ const handleParams = () => {
|
||||
} else {
|
||||
rules[p.envKey] = [Rules.requiredInput];
|
||||
if (p.envKey === 'PANEL_DB_NAME') {
|
||||
rules[p.envKey].push(Rules.linuxName);
|
||||
rules[p.envKey].push(Rules.databaseName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user