1
0
mirror of https://github.com/1Panel-dev/1Panel.git synced 2025-01-31 14:08:06 +08:00

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

This commit is contained in:
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],