diff --git a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx index 3fd020f60f..61ca562ccd 100644 --- a/web/app/components/app/configuration/tools/external-data-tool-modal.tsx +++ b/web/app/components/app/configuration/tools/external-data-tool-modal.tsx @@ -153,7 +153,7 @@ const ExternalDataToolModal: FC = ({ return } - if (localeData.variable && !/[a-zA-Z_]\w{0,29}/g.test(localeData.variable)) { + if (localeData.variable && !/^[a-zA-Z_]\w{0,29}$/.test(localeData.variable)) { notify({ type: 'error', message: t('appDebug.varKeyError.notValid', { key: t('appDebug.feature.tools.modal.variableName.title') }) }) return } diff --git a/web/app/components/rag-pipeline/components/input-field/editor/form/schema.ts b/web/app/components/rag-pipeline/components/input-field/editor/form/schema.ts index 4dfa85a559..13c707ea31 100644 --- a/web/app/components/rag-pipeline/components/input-field/editor/form/schema.ts +++ b/web/app/components/rag-pipeline/components/input-field/editor/form/schema.ts @@ -25,14 +25,14 @@ export const createInputFieldSchema = (type: PipelineInputVarType, t: TFunction, const { maxFileUploadLimit } = options const commonSchema = z.object({ type: InputTypeEnum, - variable: z.string({ - invalid_type_error: t('appDebug.varKeyError.notValid', { key: t('appDebug.variableConfig.varName') }), - }).nonempty({ + variable: z.string().nonempty({ message: t('appDebug.varKeyError.canNoBeEmpty', { key: t('appDebug.variableConfig.varName') }), }).max(MAX_VAR_KEY_LENGTH, { message: t('appDebug.varKeyError.tooLong', { key: t('appDebug.variableConfig.varName') }), }).regex(/^(?!\d)\w+/, { message: t('appDebug.varKeyError.notStartWithNumber', { key: t('appDebug.variableConfig.varName') }), + }).regex(/^[a-zA-Z_]\w{0,29}$/, { + message: t('appDebug.varKeyError.notValid', { key: t('appDebug.variableConfig.varName') }), }), label: z.string().nonempty({ message: t('appDebug.variableConfig.errorMsg.labelNameRequired'),