|
@@ -3,17 +3,14 @@
|
|
|
* SPDX-License-Identifier: MIT
|
|
* SPDX-License-Identifier: MIT
|
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
-import {
|
|
|
|
|
- FormRenderProps,
|
|
|
|
|
- FormMeta,
|
|
|
|
|
- ValidateTrigger,
|
|
|
|
|
- FeedbackLevel,
|
|
|
|
|
-} from '@flowgram.ai/free-layout-editor';
|
|
|
|
|
|
|
+import { FormRenderProps, FormMeta, ValidateTrigger } from '@flowgram.ai/free-layout-editor';
|
|
|
import {
|
|
import {
|
|
|
autoRenameRefEffect,
|
|
autoRenameRefEffect,
|
|
|
provideJsonSchemaOutputs,
|
|
provideJsonSchemaOutputs,
|
|
|
syncVariableTitle,
|
|
syncVariableTitle,
|
|
|
DisplayOutputs,
|
|
DisplayOutputs,
|
|
|
|
|
+ validateFlowValue,
|
|
|
|
|
+ validateWhenVariableSync,
|
|
|
} from '@flowgram.ai/form-materials';
|
|
} from '@flowgram.ai/form-materials';
|
|
|
import { Divider } from '@douyinfe/semi-ui';
|
|
import { Divider } from '@douyinfe/semi-ui';
|
|
|
|
|
|
|
@@ -42,18 +39,16 @@ export const defaultFormMeta: FormMeta<FlowNodeJSON> = {
|
|
|
validate: {
|
|
validate: {
|
|
|
title: ({ value }) => (value ? undefined : 'Title is required'),
|
|
title: ({ value }) => (value ? undefined : 'Title is required'),
|
|
|
'inputsValues.*': ({ value, context, formValues, name }) => {
|
|
'inputsValues.*': ({ value, context, formValues, name }) => {
|
|
|
- const valuePropetyKey = name.replace(/^inputsValues\./, '');
|
|
|
|
|
|
|
+ const valuePropertyKey = name.replace(/^inputsValues\./, '');
|
|
|
const required = formValues.inputs?.required || [];
|
|
const required = formValues.inputs?.required || [];
|
|
|
- if (
|
|
|
|
|
- required.includes(valuePropetyKey) &&
|
|
|
|
|
- (value === '' || value === undefined || value?.content === '')
|
|
|
|
|
- ) {
|
|
|
|
|
- return {
|
|
|
|
|
- message: `${valuePropetyKey} is required`,
|
|
|
|
|
- level: FeedbackLevel.Error, // Error || Warning
|
|
|
|
|
- };
|
|
|
|
|
- }
|
|
|
|
|
- return undefined;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ return validateFlowValue(value, {
|
|
|
|
|
+ node: context.node,
|
|
|
|
|
+ required: required.includes(valuePropertyKey),
|
|
|
|
|
+ errorMessages: {
|
|
|
|
|
+ required: `${valuePropertyKey} is required`,
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
/**
|
|
/**
|
|
@@ -73,6 +68,6 @@ export const defaultFormMeta: FormMeta<FlowNodeJSON> = {
|
|
|
effect: {
|
|
effect: {
|
|
|
title: syncVariableTitle,
|
|
title: syncVariableTitle,
|
|
|
outputs: provideJsonSchemaOutputs,
|
|
outputs: provideJsonSchemaOutputs,
|
|
|
- inputsValues: autoRenameRefEffect,
|
|
|
|
|
|
|
+ inputsValues: [...autoRenameRefEffect, ...validateWhenVariableSync({ scope: 'public' })],
|
|
|
},
|
|
},
|
|
|
};
|
|
};
|