diff --git a/frontend/src/global/form-rules.ts b/frontend/src/global/form-rules.ts index 1480d02b8..b99514909 100644 --- a/frontend/src/global/form-rules.ts +++ b/frontend/src/global/form-rules.ts @@ -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', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 90d1f6151..96d0ec81c 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -113,6 +113,7 @@ export default { port: '请输入正确的端口', selectHelper: '请选择正确的 {0} 文件', domain: '域名格式错误', + databaseName: '支持英文、数字、_,长度1-30', }, res: { paramError: '请求失败,请稍后重试!', diff --git a/frontend/src/views/app-store/detail/params/index.vue b/frontend/src/views/app-store/detail/params/index.vue index 516a63ab1..d9ab317aa 100644 --- a/frontend/src/views/app-store/detail/params/index.vue +++ b/frontend/src/views/app-store/detail/params/index.vue @@ -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); } } }