feat: 更新限制APP名称的正则

This commit is contained in:
zhengkunwang223 2023-03-08 22:41:45 +08:00 committed by zhengkunwang223
parent 8e76c9603a
commit 4f4fa49961
4 changed files with 22 additions and 1 deletions

View File

@ -132,6 +132,19 @@ const checkDatabaseName = (rule: any, value: any, callback: any) => {
}
};
const checkAppName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.appName')));
} else {
const reg = /^(?![_-])[a-zA-Z0-9_-]{1,29}[a-zA-Z0-9]$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.appName')));
} else {
callback();
}
}
};
const checkDomain = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.domain')));
@ -242,6 +255,7 @@ interface CommonRule {
domain: FormItemRule;
databaseName: FormItemRule;
nginxDoc: FormItemRule;
appName: FormItemRule;
paramCommon: FormItemRule;
paramComplexity: FormItemRule;
@ -368,4 +382,9 @@ export const Rules: CommonRule = {
validator: checkDoc,
trigger: 'blur',
},
appName: {
required: true,
trigger: 'blur',
validator: checkAppName,
},
};

View File

@ -143,6 +143,7 @@ export default {
paramComplexity: 'Support English, numbers, {0}, length 6-30',
paramUrlAndPort: 'The format is http(s)://(domain name/ip):(port)',
nginxDoc: 'Only supports English case, numbers, and .',
appName: 'Support English, numbers, - and _, length 2-30, and cannot start and end with -_',
},
res: {
paramError: 'The request failed, please try again later!',

View File

@ -148,6 +148,7 @@ export default {
paramComplexity: '支持英文数字{0},长度6-30',
paramUrlAndPort: '格式为 http(s)://(域名/ip):(端口)',
nginxDoc: '仅支持英文大小写数字.',
appName: '支持英文数字-和_,长度2-30,并且不能以-_开头和结尾',
},
res: {
paramError: '请求失败,请稍后重试!',

View File

@ -62,7 +62,7 @@ const installData = ref<InstallRrops>({
let open = ref(false);
let form = ref<{ [key: string]: any }>({});
let rules = ref<FormRules>({
NAME: [Rules.linuxName],
NAME: [Rules.appName],
});
let loading = ref(false);
const paramForm = ref<FormInstance>();