chore: http node check

This commit is contained in:
Joel
2024-03-29 13:01:36 +08:00
parent 46cc635e05
commit 91b84d8f1e
3 changed files with 11 additions and 7 deletions

View File

@@ -29,15 +29,17 @@ const nodeDefault: NodeDefault<HttpNodeType> = {
const nodes = isChatMode ? ALL_CHAT_AVAILABLE_BLOCKS : ALL_COMPLETION_AVAILABLE_BLOCKS
return nodes
},
checkValid(payload: HttpNodeType) {
let isValid = true
checkValid(payload: HttpNodeType, t: any) {
let errorMessages = ''
if (payload.type) {
isValid = true
errorMessages = ''
}
if (!errorMessages && !payload.url)
errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('workflow.nodes.http.api') })
if (!errorMessages && !payload.url.startsWith('http://') && !payload.url.startsWith('https://'))
errorMessages = t('workflow.nodes.http.notStartWithHttp')
return {
isValid,
isValid: !errorMessages,
errorMessage: errorMessages,
}
},

View File

@@ -203,6 +203,7 @@ const translation = {
http: {
inputVars: 'Input Variables',
api: 'API',
notStartWithHttp: 'API should start with http:// or https://',
key: 'Key',
value: 'Value',
bulkEdit: 'Bulk Edit',

View File

@@ -203,6 +203,7 @@ const translation = {
http: {
inputVars: '输入变量',
api: 'API',
notStartWithHttp: 'API 应该以 http:// 或 https:// 开头',
key: '键',
value: '值',
bulkEdit: '批量编辑',