mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-01-31 22:18:07 +08:00
feat: 修改校验规则
This commit is contained in:
parent
be974ad0a8
commit
bbf0349ae7
@ -82,24 +82,11 @@ const checkImageName = (rule: any, value: any, callback: any) => {
|
|||||||
|
|
||||||
const checkLinuxName = (rule: any, value: any, callback: any) => {
|
const checkLinuxName = (rule: any, value: any, callback: any) => {
|
||||||
if (value === '' || typeof value === 'undefined' || value == null) {
|
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 {
|
} else {
|
||||||
const reg = /^[a-zA-Z0-9]{1}[a-zA-Z0-9_.-]{0,30}$/;
|
const reg = /^((?!\\|\/|:|\*|\?|<|>|\||'|%).){1,30}$/;
|
||||||
if (!reg.test(value) && value !== '') {
|
if (!reg.test(value) && value !== '') {
|
||||||
callback(new Error(i18n.global.t('commons.rule.linuxName')));
|
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')));
|
|
||||||
} else {
|
} else {
|
||||||
callback();
|
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 {
|
interface CommonRule {
|
||||||
requiredInput: FormItemRule;
|
requiredInput: FormItemRule;
|
||||||
requiredSelect: FormItemRule;
|
requiredSelect: FormItemRule;
|
||||||
|
@ -108,7 +108,7 @@ export default {
|
|||||||
imageName: '支持英文、中文、数字、:.-_,长度1-30',
|
imageName: '支持英文、中文、数字、:.-_,长度1-30',
|
||||||
complexityPassword: '请输入 8 位以上、必须含有字母、数字、特殊符号的密码',
|
complexityPassword: '请输入 8 位以上、必须含有字母、数字、特殊符号的密码',
|
||||||
commonPassword: '请输入 6 位以上长度密码',
|
commonPassword: '请输入 6 位以上长度密码',
|
||||||
linuxName: '支持英文、数字、._-长度1-30',
|
linuxName: '长度1-30,名称不能含有{0}等符号',
|
||||||
email: '请输入正确的邮箱',
|
email: '请输入正确的邮箱',
|
||||||
number: '请输入正确的数字',
|
number: '请输入正确的数字',
|
||||||
ip: '请输入正确的 IP 地址',
|
ip: '请输入正确的 IP 地址',
|
||||||
|
@ -82,7 +82,7 @@ const handleClose = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const rules = reactive<FormRules>({
|
const rules = reactive<FormRules>({
|
||||||
name: [Rules.requiredInput],
|
name: [Rules.requiredInput, Rules.linuxName],
|
||||||
path: [Rules.requiredInput],
|
path: [Rules.requiredInput],
|
||||||
isSymlink: [Rules.requiredInput],
|
isSymlink: [Rules.requiredInput],
|
||||||
linkPath: [Rules.requiredInput],
|
linkPath: [Rules.requiredInput],
|
||||||
|
@ -106,10 +106,9 @@ let acmeReq = reactive({
|
|||||||
});
|
});
|
||||||
let dnsAccounts = ref<Website.DnsAccount[]>();
|
let dnsAccounts = ref<Website.DnsAccount[]>();
|
||||||
let acmeAccounts = ref<Website.AcmeAccount[]>();
|
let acmeAccounts = ref<Website.AcmeAccount[]>();
|
||||||
// let domains = ref<Website.Domain[]>([]);
|
|
||||||
let sslForm = ref<FormInstance>();
|
let sslForm = ref<FormInstance>();
|
||||||
let rules = ref({
|
let rules = ref({
|
||||||
primaryDomain: [Rules.requiredInput],
|
primaryDomain: [Rules.requiredInput, Rules.domain],
|
||||||
acmeAccountId: [Rules.requiredSelectBusiness],
|
acmeAccountId: [Rules.requiredSelectBusiness],
|
||||||
dnsAccountId: [Rules.requiredSelectBusiness],
|
dnsAccountId: [Rules.requiredSelectBusiness],
|
||||||
provider: [Rules.requiredInput],
|
provider: [Rules.requiredInput],
|
||||||
|
@ -92,7 +92,7 @@ let open = ref();
|
|||||||
let loading = ref(false);
|
let loading = ref(false);
|
||||||
let accountForm = ref<FormInstance>();
|
let accountForm = ref<FormInstance>();
|
||||||
let rules = ref({
|
let rules = ref({
|
||||||
name: [Rules.requiredInput],
|
name: [Rules.requiredInput, Rules.linuxName],
|
||||||
type: [Rules.requiredSelect],
|
type: [Rules.requiredSelect],
|
||||||
authorization: {
|
authorization: {
|
||||||
accessKey: [Rules.requiredInput],
|
accessKey: [Rules.requiredInput],
|
||||||
|
@ -167,7 +167,7 @@ const website = ref({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
let rules = reactive({
|
let rules = reactive({
|
||||||
primaryDomain: [Rules.linuxName],
|
primaryDomain: [Rules.domain],
|
||||||
alias: [Rules.linuxName],
|
alias: [Rules.linuxName],
|
||||||
type: [Rules.requiredInput],
|
type: [Rules.requiredInput],
|
||||||
webSiteGroupId: [Rules.requiredSelectBusiness],
|
webSiteGroupId: [Rules.requiredSelectBusiness],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user