@@ -64,13 +64,14 @@ public WorkflowValidator setSource(String source) {
64
64
@ Override
65
65
public Collection <ValidationError > validate () {
66
66
validationErrors .clear ();
67
- if (workflow == null && schemaValidationEnabled && source != null ) {
67
+ if (workflow == null ) {
68
68
try {
69
-
70
- JsonSchemaFactory .getInstance (VersionFlag .V202012 )
71
- .getSchema (workflowSchema )
72
- .validate (Utils .getNode (source ))
73
- .forEach (m -> addValidationError (m .getMessage (), ValidationError .SCHEMA_VALIDATION ));
69
+ if (schemaValidationEnabled && source != null ) {
70
+ JsonSchemaFactory .getInstance (VersionFlag .V7 )
71
+ .getSchema (workflowSchema )
72
+ .validate (Utils .getNode (source ))
73
+ .forEach (m -> addValidationError (m .getMessage (), ValidationError .SCHEMA_VALIDATION ));
74
+ }
74
75
} catch (IOException e ) {
75
76
logger .error ("Unexpected error during validation" , e );
76
77
}
@@ -163,17 +164,6 @@ public Collection<ValidationError> validate() {
163
164
}
164
165
165
166
if (action .getEventRef () != null ) {
166
- if (action .getEventRef ().getTriggerEventRef ().isEmpty ()) {
167
- addValidationError (
168
- "Operation State action trigger eventRef does not reference an existing workflow event definition" ,
169
- ValidationError .WORKFLOW_VALIDATION );
170
- }
171
-
172
- if (action .getEventRef ().getResultEventRef ().isEmpty ()) {
173
- addValidationError (
174
- "Operation State action results eventRef does not reference an existing workflow event definition" ,
175
- ValidationError .WORKFLOW_VALIDATION );
176
- }
177
167
178
168
if (!haveEventsDefinition (
179
169
action .getEventRef ().getTriggerEventRef (), events )) {
@@ -357,22 +347,19 @@ private boolean haveFunctionDefinition(String functionName, List<FunctionDefinit
357
347
}
358
348
359
349
private boolean haveEventsDefinition (String eventName , List <EventDefinition > events ) {
350
+ if (eventName == null ) {
351
+ return true ;
352
+ }
360
353
if (events != null ) {
361
354
EventDefinition eve =
362
355
events .stream ().filter (e -> e .getName ().equals (eventName )).findFirst ().orElse (null );
363
-
364
356
return eve == null ? false : true ;
365
357
} else {
366
358
return false ;
367
359
}
368
360
}
369
361
370
- private static final Set <String > skipMessages =
371
- Set .of (
372
- "$.start: string found, object expected" ,
373
- "$.functions: array found, object expected" ,
374
- "$.events: array found, object expected" ,
375
- "$.retries: array found, object expected" );
362
+ private static final Set <String > skipMessages = Set .of ("$.start: string found, object expected" );
376
363
377
364
private void addValidationError (String message , String type ) {
378
365
if (skipMessages .contains (message )) {
@@ -385,7 +372,6 @@ private void addValidationError(String message, String type) {
385
372
}
386
373
387
374
private class Validation {
388
-
389
375
final Set <String > states = new HashSet <>();
390
376
Integer endStates = 0 ;
391
377
0 commit comments