feat: 增加主域名和代号的校验

pull/48/head
zhengkunwang223 2022-11-25 15:55:31 +08:00 committed by zhengkunwang223
parent 324903f7a0
commit b1a4d9df00
3 changed files with 22 additions and 2 deletions

View File

@ -41,11 +41,25 @@ const checkName = (rule: any, value: any, callback: any) => {
}
};
const checkLinuxName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.linuxName')));
} 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.linuxName')));
} else {
callback();
}
}
};
interface CommonRule {
requiredInput: FormItemRule;
requiredSelect: FormItemRule;
requiredSelectBusiness: FormItemRule;
name: FormItemRule;
linuxName: FormItemRule;
password: FormItemRule;
email: FormItemRule;
number: FormItemRule;
@ -77,6 +91,11 @@ export const Rules: CommonRule = {
validator: checkName,
trigger: 'blur',
},
linuxName: {
required: true,
validator: checkLinuxName,
trigger: 'blur',
},
password: {
validator: complexityPassword,
trigger: 'blur',

View File

@ -100,6 +100,7 @@ export default {
commonName: '.-_,1-30',
complexityPassword: ' 8 ',
commonPassword: ' 6 ',
linuxName: '.-_,1-30',
email: '',
number: '',
ip: ' IP ',

View File

@ -141,8 +141,8 @@ const website = ref({
},
});
let rules = ref({
primaryDomain: [Rules.requiredInput],
alias: [Rules.requiredInput],
primaryDomain: [Rules.linuxName],
alias: [Rules.linuxName],
type: [Rules.requiredInput],
webSiteGroupId: [Rules.requiredSelectBusiness],
appInstallId: [Rules.requiredSelectBusiness],