feat: 修改校验规则

This commit is contained in:
zhengkunwang223 2022-12-23 14:50:28 +08:00 committed by zhengkunwang223
parent be974ad0a8
commit bbf0349ae7
6 changed files with 22 additions and 22 deletions

View file

@ -82,24 +82,11 @@ const checkImageName = (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')));
callback(new Error(i18n.global.t('commons.rule.linuxName', ['/\\:*?"<>|'])));
} else {
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_.-]{0,30}$/;
const reg = /^((?!\\|\/|:|\*|\?|<|>|\||'|%).){1,30}$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.linuxName')));
} 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')));
} 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')));
callback(new Error(i18n.global.t('commons.rule.linuxName', ['/\\:*?"<>|'])));
} else {
callback();
}
@ -119,6 +106,20 @@ const checkDatabaseName = (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 =
/^([\w\u4e00-\u9fa5\-\*]{1,100}\.){1,10}([\w\u4e00-\u9fa5\-]{1,24}|[\w\u4e00-\u9fa5\-]{1,24}\.[\w\u4e00-\u9fa5\-]{1,24})$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.domain')));
} else {
callback();
}
}
};
interface CommonRule {
requiredInput: FormItemRule;
requiredSelect: FormItemRule;

View file

@ -108,7 +108,7 @@ export default {
imageName: '支持英文中文数字:.-_,长度1-30',
complexityPassword: '请输入 8 位以上必须含有字母数字特殊符号的密码',
commonPassword: '请输入 6 位以上长度密码',
linuxName: '支持英文数字._-长度1-30',
linuxName: '长度1-30名称不能含有{0}等符号',
email: '请输入正确的邮箱',
number: '请输入正确的数字',
ip: '请输入正确的 IP 地址',

View file

@ -82,7 +82,7 @@ const handleClose = () => {
};
const rules = reactive<FormRules>({
name: [Rules.requiredInput],
name: [Rules.requiredInput, Rules.linuxName],
path: [Rules.requiredInput],
isSymlink: [Rules.requiredInput],
linkPath: [Rules.requiredInput],

View file

@ -106,10 +106,9 @@ let acmeReq = reactive({
});
let dnsAccounts = ref<Website.DnsAccount[]>();
let acmeAccounts = ref<Website.AcmeAccount[]>();
// let domains = ref<Website.Domain[]>([]);
let sslForm = ref<FormInstance>();
let rules = ref({
primaryDomain: [Rules.requiredInput],
primaryDomain: [Rules.requiredInput, Rules.domain],
acmeAccountId: [Rules.requiredSelectBusiness],
dnsAccountId: [Rules.requiredSelectBusiness],
provider: [Rules.requiredInput],

View file

@ -92,7 +92,7 @@ let open = ref();
let loading = ref(false);
let accountForm = ref<FormInstance>();
let rules = ref({
name: [Rules.requiredInput],
name: [Rules.requiredInput, Rules.linuxName],
type: [Rules.requiredSelect],
authorization: {
accessKey: [Rules.requiredInput],

View file

@ -167,7 +167,7 @@ const website = ref({
},
});
let rules = reactive({
primaryDomain: [Rules.linuxName],
primaryDomain: [Rules.domain],
alias: [Rules.linuxName],
type: [Rules.requiredInput],
webSiteGroupId: [Rules.requiredSelectBusiness],