mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +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 {
|
interface CommonRule {
|
||||||
requiredInput: FormItemRule;
|
requiredInput: FormItemRule;
|
||||||
requiredSelect: FormItemRule;
|
requiredSelect: FormItemRule;
|
||||||
@ -93,6 +106,7 @@ interface CommonRule {
|
|||||||
ip: FormItemRule;
|
ip: FormItemRule;
|
||||||
port: FormItemRule;
|
port: FormItemRule;
|
||||||
domain: FormItemRule;
|
domain: FormItemRule;
|
||||||
|
databaseName: FormItemRule;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Rules: CommonRule = {
|
export const Rules: CommonRule = {
|
||||||
@ -129,6 +143,11 @@ export const Rules: CommonRule = {
|
|||||||
validator: checkLinuxName,
|
validator: checkLinuxName,
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
|
databaseName: {
|
||||||
|
required: true,
|
||||||
|
validator: checkDatabaseName,
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
password: {
|
password: {
|
||||||
validator: complexityPassword,
|
validator: complexityPassword,
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
|
@ -113,6 +113,7 @@ export default {
|
|||||||
port: '请输入正确的端口',
|
port: '请输入正确的端口',
|
||||||
selectHelper: '请选择正确的 {0} 文件',
|
selectHelper: '请选择正确的 {0} 文件',
|
||||||
domain: '域名格式错误',
|
domain: '域名格式错误',
|
||||||
|
databaseName: '支持英文、数字、_,长度1-30',
|
||||||
},
|
},
|
||||||
res: {
|
res: {
|
||||||
paramError: '请求失败,请稍后重试!',
|
paramError: '请求失败,请稍后重试!',
|
||||||
|
@ -108,7 +108,7 @@ const handleParams = () => {
|
|||||||
} else {
|
} else {
|
||||||
rules[p.envKey] = [Rules.requiredInput];
|
rules[p.envKey] = [Rules.requiredInput];
|
||||||
if (p.envKey === 'PANEL_DB_NAME') {
|
if (p.envKey === 'PANEL_DB_NAME') {
|
||||||
rules[p.envKey].push(Rules.linuxName);
|
rules[p.envKey].push(Rules.databaseName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user