mirror of
https://github.com/langgenius/dify.git
synced 2026-05-05 01:48:04 +08:00
add check valid for human input
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import type { NodeDefault, Var } from '../../types'
|
||||
import type { HumanInputNodeType } from './types'
|
||||
import { splitByOutputVar } from '@/app/components/base/chat/chat/answer/human-input-content/utils'
|
||||
import { BlockClassificationEnum } from '@/app/components/workflow/block-selector/types'
|
||||
import { BlockEnum, VarType } from '@/app/components/workflow/types'
|
||||
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
||||
@ -21,6 +22,12 @@ const buildOutputVars = (variables: string[]): Var[] => {
|
||||
})
|
||||
}
|
||||
|
||||
const checkInputFields = (formContent: string): boolean => {
|
||||
const outputVarRegex = /\{\{#\$output\.[^#]+#\}\}/
|
||||
const contentList = splitByOutputVar(formContent)
|
||||
return contentList.filter(content => outputVarRegex.test(content)).length > 0
|
||||
}
|
||||
|
||||
const nodeDefault: NodeDefault<HumanInputNodeType> = {
|
||||
metaData,
|
||||
defaultValue: {
|
||||
@ -39,6 +46,12 @@ const nodeDefault: NodeDefault<HumanInputNodeType> = {
|
||||
if (!errorMessages && payload.delivery_methods.length > 0 && !payload.delivery_methods.some(method => method.enabled))
|
||||
errorMessages = t(`${i18nPrefix}.noDeliveryMethodEnabled`, { ns: 'workflow' })
|
||||
|
||||
if (!errorMessages && !payload.form_content.trim())
|
||||
errorMessages = t(`${i18nPrefix}.noFormContent`, { ns: 'workflow' })
|
||||
|
||||
if (!errorMessages && !checkInputFields(payload.form_content))
|
||||
errorMessages = t(`${i18nPrefix}.noFormContentInputField`, { ns: 'workflow' })
|
||||
|
||||
if (!errorMessages && !payload.user_actions.length)
|
||||
errorMessages = t(`${i18nPrefix}.noUserActions`, { ns: 'workflow' })
|
||||
|
||||
|
||||
Reference in New Issue
Block a user