@@ -144,40 +144,7 @@ public List<ValidationError> validate() {
144144
145145 if (s instanceof OperationState ) {
146146 OperationState operationState = (OperationState ) s ;
147-
148- List <Action > actions = operationState .getActions ();
149- for (Action action : actions ) {
150- if (action .getFunctionRef () != null ) {
151- if (action .getFunctionRef ().getRefName ().isEmpty ()) {
152- addValidationError (
153- "Operation State action functionRef should not be null or empty" ,
154- ValidationError .WORKFLOW_VALIDATION );
155- }
156-
157- if (!haveFunctionDefinition (
158- action .getFunctionRef ().getRefName (), functions )) {
159- addValidationError (
160- "Operation State action functionRef does not reference an existing workflow function definition" ,
161- ValidationError .WORKFLOW_VALIDATION );
162- }
163- }
164-
165- if (action .getEventRef () != null ) {
166-
167- if (!haveEventsDefinition (
168- action .getEventRef ().getTriggerEventRef (), events )) {
169- addValidationError (
170- "Operation State action trigger event def does not reference an existing workflow event definition" ,
171- ValidationError .WORKFLOW_VALIDATION );
172- }
173-
174- if (!haveEventsDefinition (action .getEventRef ().getResultEventRef (), events )) {
175- addValidationError (
176- "Operation State action results event def does not reference an existing workflow event definition" ,
177- ValidationError .WORKFLOW_VALIDATION );
178- }
179- }
180- }
147+ checkActionsDefinition (operationState .getActions (), functions , events );
181148 }
182149
183150 if (s instanceof EventState ) {
@@ -281,6 +248,7 @@ public List<ValidationError> validate() {
281248
282249 if (s instanceof ForEachState ) {
283250 ForEachState forEachState = (ForEachState ) s ;
251+ checkActionsDefinition (forEachState .getActions (), functions , events );
284252 if (forEachState .getInputCollection () == null
285253 || forEachState .getInputCollection ().isEmpty ()) {
286254 addValidationError (
@@ -334,6 +302,50 @@ public WorkflowValidator reset() {
334302 return this ;
335303 }
336304
305+ private void checkActionsDefinition (
306+ List <Action > actions , List <FunctionDefinition > functions , List <EventDefinition > events ) {
307+ if (actions == null ) {
308+ return ;
309+ }
310+ for (Action action : actions ) {
311+ if (action .getFunctionRef () != null ) {
312+ if (action .getFunctionRef ().getRefName ().isEmpty ()) {
313+ addValidationError (
314+ String .format (
315+ "State action '%s' functionRef should not be null or empty" , action .getName ()),
316+ ValidationError .WORKFLOW_VALIDATION );
317+ }
318+
319+ if (!haveFunctionDefinition (action .getFunctionRef ().getRefName (), functions )) {
320+ addValidationError (
321+ String .format (
322+ "State action '%s' functionRef does not reference an existing workflow function definition" ,
323+ action .getName ()),
324+ ValidationError .WORKFLOW_VALIDATION );
325+ }
326+ }
327+
328+ if (action .getEventRef () != null ) {
329+
330+ if (!haveEventsDefinition (action .getEventRef ().getTriggerEventRef (), events )) {
331+ addValidationError (
332+ String .format (
333+ "State action '%s' trigger event def does not reference an existing workflow event definition" ,
334+ action .getName ()),
335+ ValidationError .WORKFLOW_VALIDATION );
336+ }
337+
338+ if (!haveEventsDefinition (action .getEventRef ().getResultEventRef (), events )) {
339+ addValidationError (
340+ String .format (
341+ "State action '%s' results event def does not reference an existing workflow event definition" ,
342+ action .getName ()),
343+ ValidationError .WORKFLOW_VALIDATION );
344+ }
345+ }
346+ }
347+ }
348+
337349 private boolean haveFunctionDefinition (String functionName , List <FunctionDefinition > functions ) {
338350 if (functions != null ) {
339351 FunctionDefinition fun =
0 commit comments