fix: Fix the issue of compose name validation errors (#7382)

Refs #7380
pull/7385/head
ssongliu 2024-12-17 12:16:12 +08:00 committed by GitHub
parent 4c03a482bd
commit 9539fd40eb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 24 additions and 1 deletions

View File

@ -220,6 +220,19 @@ const checkImageName = (rule: any, value: any, callback: any) => {
}
};
const checkComposeName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.composeName')));
} else {
const reg = /^[a-z0-9]{1}[a-z0-9_-]{0,256}$/;
if (!reg.test(value) && value !== '') {
callback(new Error(i18n.global.t('commons.rule.composeName')));
} else {
callback();
}
}
};
const checkVolumeName = (rule: any, value: any, callback: any) => {
if (value === '' || typeof value === 'undefined' || value == null) {
callback(new Error(i18n.global.t('commons.rule.volumeName')));
@ -564,6 +577,7 @@ interface CommonRule {
simplePassword: FormItemRule;
dbName: FormItemRule;
imageName: FormItemRule;
composeName: FormItemRule;
volumeName: FormItemRule;
linuxName: FormItemRule;
password: FormItemRule;
@ -644,6 +658,11 @@ export const Rules: CommonRule = {
validator: checkImageName,
trigger: 'blur',
},
composeName: {
required: true,
validator: checkComposeName,
trigger: 'blur',
},
volumeName: {
required: true,
validator: checkVolumeName,

View File

@ -195,6 +195,8 @@ const message = {
dbName: `This field mustn't start with underscore character and must consist of English, numbers, and "_" characters with a length of 1-64.`,
imageName:
'This field must consist of English, numbers, ":", "@", "/", ".", "-", and "_" characters with a length of 1-256.',
composeName:
'Supports non-special characters at the beginning, lowercase letters, numbers, - and _, length 1-256',
volumeName:
'This field must consist of English, numbers, ".", "-", and "_" characters with a length of 2-30.',
supervisorName:

View File

@ -194,6 +194,7 @@ const message = {
simplePassword: '_,1-30',
dbName: '.-_1-64',
imageName: ':@/.-_,1-256',
composeName: '-_1-256',
volumeName: '.-_,2-30',
supervisorName: ',-_,1-128',
complexityPassword: ' 8-30 ',

View File

@ -193,6 +193,7 @@ const message = {
simplePassword: '线_,1-30',
dbName: '.-_,1-64',
imageName: ':@/.-_,1-256',
composeName: '-_,1-256',
volumeName: '.-_,2-30',
supervisorName: ',-_,1-128',
complexityPassword: ' 8-30 ',

View File

@ -169,7 +169,7 @@ const form = reactive({
envFileContent: `env_file:\n - 1panel.env`,
});
const rules = reactive({
name: [Rules.requiredInput, Rules.imageName],
name: [Rules.requiredInput, Rules.composeName],
path: [Rules.requiredInput],
template: [Rules.requiredSelect],
});