Skip to content

Commit 6be910e

Browse files
committed
feat(ui): Support 'validate' as alias for 'validation' function name
Add 'validate' as an accepted built-in function type alongside 'validation' in all UI components and bump version to 2.0.18. Also add optional path field to ValidationRule type.
1 parent 2da12e5 commit 6be910e

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

ui/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@goplasmatic/dataflow-ui",
3-
"version": "2.0.17",
3+
"version": "2.0.18",
44
"type": "module",
55
"description": "React visualization library for dataflow-rs workflow engine",
66
"author": "Plasmatic Engineering <shankar@goplasmatic.io>",

ui/src/components/workflow-visualizer/cards/TaskRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function getTaskSubtitle(task: Task): string | null {
2222
}
2323
}
2424

25-
if (fn.name === 'validation' && fn.input) {
25+
if ((fn.name === 'validation' || fn.name === 'validate') && fn.input) {
2626
const input = fn.input as unknown as ValidationFunctionInput;
2727
if (input.rules) {
2828
const count = input.rules.length;

ui/src/components/workflow-visualizer/components/TaskNode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function TaskNode({
116116

117117
const hasCondition = task.condition !== undefined && task.condition !== null && task.condition !== true;
118118
const mappings = functionName === 'map' ? (input?.mappings as MappingItem[]) || [] : [];
119-
const rules = functionName === 'validation' ? (input?.rules as ValidationRule[]) || [] : [];
119+
const rules = (functionName === 'validation' || functionName === 'validate') ? (input?.rules as ValidationRule[]) || [] : [];
120120
const hasChildren = hasCondition || mappings.length > 0 || rules.length > 0;
121121

122122
const isTaskSelected = selection.type === 'task' &&

ui/src/components/workflow-visualizer/views/detail-views/TaskContent.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function TaskContent({ selection }: TaskContentProps) {
2828
if (functionName === 'map') {
2929
// For aggregate map view, use context before first mapping
3030
debugData = getMappingContext(step, 0);
31-
} else if (functionName === 'validation' && step.message) {
31+
} else if ((functionName === 'validation' || functionName === 'validate') && step.message) {
3232
// Validation is read-only, use task-level context
3333
debugData = step.message.context;
3434
}
@@ -55,7 +55,7 @@ export function TaskContent({ selection }: TaskContentProps) {
5555
}
5656

5757
// For validation function, show all rules as AND expression
58-
if (functionName === 'validation') {
58+
if (functionName === 'validation' || functionName === 'validate') {
5959
const rules = (input?.rules as ValidationRule[]) || [];
6060
const andExpression: JsonLogicValue = {
6161
and: rules.map((rule) => rule.logic),

ui/src/types/workflow.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,8 @@ export interface ValidationRule {
9191
logic: JsonLogicValue;
9292
/** Error message if validation fails */
9393
message: string;
94+
/** Optional path for the validation target */
95+
path?: string;
9496
}
9597

9698
/**
@@ -103,13 +105,13 @@ export interface ValidationFunctionInput {
103105
/**
104106
* Built-in function types
105107
*/
106-
export type BuiltinFunctionType = 'map' | 'validation';
108+
export type BuiltinFunctionType = 'map' | 'validation' | 'validate';
107109

108110
/**
109111
* Check if a function is a built-in type
110112
*/
111113
export function isBuiltinFunction(name: string): name is BuiltinFunctionType {
112-
return name === 'map' || name === 'validation';
114+
return name === 'map' || name === 'validation' || name === 'validate';
113115
}
114116

115117
/**
@@ -123,6 +125,7 @@ export function getFunctionDisplayInfo(name: string): {
123125
switch (name) {
124126
case 'map':
125127
return { label: 'Map', colorClass: 'df-function-badge-map', Icon: ArrowRightLeft };
128+
case 'validate':
126129
case 'validation':
127130
return { label: 'Validation', colorClass: 'df-function-badge-validation', Icon: CheckCircle };
128131
default:

0 commit comments

Comments
 (0)