feat: 修改正则表达式

This commit is contained in:
zhengkunwang223 2022-12-12 15:51:55 +08:00 committed by zhengkunwang223
parent b7d55801cd
commit 5b7872d896
3 changed files with 22 additions and 2 deletions

View File

@ -67,6 +67,19 @@ const checkLinuxName = (rule: any, value: any, callback: any) => {
}
};
const checkDomain = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.domain')));
} else {
const reg = /^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.domain')));
} else {
callback();
}
}
};
interface CommonRule {
requiredInput: FormItemRule;
requiredSelect: FormItemRule;
@ -79,6 +92,7 @@ interface CommonRule {
number: FormItemRule;
ip: FormItemRule;
port: FormItemRule;
domain: FormItemRule;
}
export const Rules: CommonRule = {
@ -145,4 +159,9 @@ export const Rules: CommonRule = {
type: 'number',
message: i18n.global.t('commons.rule.port'),
},
domain: {
required: true,
validator: checkDomain,
trigger: 'blur',
},
};

View File

@ -104,12 +104,13 @@ export default {
imageName: '支持英文中文数字:.-_,长度1-30',
complexityPassword: '请输入 8 位以上必须含有字母数字特殊符号的密码',
commonPassword: '请输入 6 位以上长度密码',
linuxName: '支持英文数字._,长度1-30',
linuxName: '支持英文数字._长度1-30',
email: '请输入正确的邮箱',
number: '请输入正确的数字',
ip: '请输入正确的 IP 地址',
port: '请输入正确的端口',
selectHelper: '请选择正确的 {0} 文件',
domain: '域名格式错误',
},
res: {
paramError: '请求失败,请稍后重试!',

View File

@ -169,7 +169,7 @@ let rules = reactive({
appType: [Rules.requiredInput],
proxy: [Rules.requiredInput],
appinstall: {
name: [Rules.linuxName],
name: [Rules.name],
appId: [Rules.requiredSelectBusiness],
params: {},
},