| | |
| | | } from '@/app/components/base/prompt-editor/constants' |
| | | import { InputVarType } from '@/app/components/workflow/types' |
| | | |
| | | const otherAllowedRegex = /^\w+$/ |
| | | const otherAllowedRegex = /^[a-zA-Z0-9_]+$/ |
| | | |
| | | export const getNewVar = (key: string, type: string) => { |
| | | const { ...rest } = VAR_ITEM_TEMPLATE |
| | |
| | | return 'tooLong' |
| | | |
| | | if (otherAllowedRegex.test(key)) { |
| | | if (/\d/.test(key[0])) |
| | | if (/[0-9]/.test(key[0])) |
| | | return 'notStartWithNumber' |
| | | |
| | | return true |
| | |
| | | return { isValid, errorKey, errorMessageKey } |
| | | } |
| | | |
| | | const varRegex = /\{\{([a-zA-Z_]\w*)\}\}/g |
| | | const varRegex = /\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g |
| | | export const getVars = (value: string) => { |
| | | if (!value) |
| | | return [] |
| | |
| | | }) |
| | | return res |
| | | } |
| | | |
| | | // Set the value of basePath |
| | | // example: /dify |
| | | export const basePath = '' |