@@ -34,10 +34,11 @@ public OpenAPIWorkflowValidatorResult validate() {
3434 result .addError ("'workflowsSpec' is undefined" );
3535 }
3636
37+ // Info
3738 result .addErrors (validateInfo (openAPIWorkflow .getInfo ()));
38-
39+ // SourceDescriptions
3940 result .addErrors (validateSourceDescriptions (openAPIWorkflow .getSourceDescriptions ()));
40-
41+ // Workflows
4142 if (openAPIWorkflow .getWorkflows () == null || openAPIWorkflow .getWorkflows ().isEmpty ()) {
4243 result .addError ("'Workflows' is undefined" );
4344 }
@@ -53,6 +54,8 @@ public OpenAPIWorkflowValidatorResult validate() {
5354 }
5455 }
5556 }
57+ // Components
58+ result .addErrors (validateComponents (openAPIWorkflow .getComponents ()));
5659
5760 if (!result .getErrors ().isEmpty ()) {
5861 result .setValid (false );
@@ -318,6 +321,35 @@ List<String> validateCriterion(Criterion criterion, String stepId) {
318321 return errors ;
319322 }
320323
324+ List <String > validateComponents (Components components ) {
325+ List <String > errors = new ArrayList <>();
326+
327+ if (components != null ) {
328+ if (components .getParameters () != null ) {
329+
330+ for (String key : components .getParameters ().keySet ()) {
331+ if (isValidComponentKey (key )) {
332+ errors .add ("'Component parameter " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
333+ }
334+ }
335+
336+ for (Parameter parameter : components .getParameters ().values ()) {
337+ errors .addAll (validateParameter (parameter , "Components" ));
338+ }
339+ }
340+ if (components .getInputs () != null ) {
341+
342+ for (String key : components .getInputs ().keySet ()) {
343+ if (isValidComponentKey (key )) {
344+ errors .add ("'Component input " + key + " is invalid (should match regex " + getComponentKeyRegularExpression () + ")" );
345+ }
346+ }
347+
348+ }
349+ }
350+
351+ return errors ;
352+ }
321353
322354 boolean isValidWorkflowId (String workflowId ) {
323355 return Pattern .matches (getWorkflowIdRegularExpression (), workflowId );
@@ -327,13 +359,21 @@ boolean isValidStepId(String stepId) {
327359 return Pattern .matches (getStepIdRegularExpression (), stepId );
328360 }
329361
362+ boolean isValidComponentKey (String key ) {
363+ return Pattern .matches (getComponentKeyRegularExpression (), key );
364+ }
365+
330366 String getStepIdRegularExpression () {
331367 return "[A-Za-z0-9_\\ -]+" ;
332368 }
333369
334370 String getWorkflowIdRegularExpression () {
335371 return "[A-Za-z0-9_\\ \\ -]++" ;
336372 }
373+ String getComponentKeyRegularExpression () {
374+ return "^[a-zA-Z0-9\\ .\\ -_]+$" ;
375+ }
376+
337377 boolean isValidOutputsKey (String key ) {
338378 return Pattern .matches (getOutputsKeyRegularExpression (), key );
339379 }
0 commit comments