mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2024-11-10 17:13:30 +08:00
feat: 修改校验规则
This commit is contained in:
parent
be974ad0a8
commit
bbf0349ae7
6 changed files with 22 additions and 22 deletions
|
@ -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;
|
||||
|
|
|
@ -108,7 +108,7 @@ export default {
|
|||
imageName: '支持英文、中文、数字、:.-_,长度1-30',
|
||||
complexityPassword: '请输入 8 位以上、必须含有字母、数字、特殊符号的密码',
|
||||
commonPassword: '请输入 6 位以上长度密码',
|
||||
linuxName: '支持英文、数字、._-长度1-30',
|
||||
linuxName: '长度1-30,名称不能含有{0}等符号',
|
||||
email: '请输入正确的邮箱',
|
||||
number: '请输入正确的数字',
|
||||
ip: '请输入正确的 IP 地址',
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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],
|
||||
|
|
|
@ -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],
|
||||
|
|
Loading…
Reference in a new issue