mirror of
https://github.com/langgenius/dify.git
synced 2025-12-28 10:32:31 +00:00
feat: update variable validation regex for consistency in ExternalDataToolModal and schema
This commit is contained in:
parent
7d7fd18e65
commit
c7cec120a6
@ -153,7 +153,7 @@ const ExternalDataToolModal: FC<ExternalDataToolModalProps> = ({
|
||||
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
|
||||
}
|
||||
|
||||
@ -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'),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user