@@ -53,20 +53,22 @@ It will create a symbolic link from globally-installed `sdk-typescript` to `node
5353#### Create Workflow using builder API
5454
5555``` typescript
56- const workflow = workflowJsonBuilder ()
57- .id (" helloworld" )
58- .version (" 1.0" )
59- .name (" Hello World Workflow" )
60- .description (" Inject Hello World" )
61- .start (" Hello State" )
62- .states ([injectstateBuilder ()
63- .type (" inject" )
64- .name (" Hello State" )
65- .data ({
66- " result" : " Hello World!"
67- })
68- .end (true ).build ()])
69- .build ());
56+ const workflow = workflowBuilder ()
57+ .id (" helloworld" )
58+ .version (" 1.0" )
59+ .name (" Hello World Workflow" )
60+ .description (" Inject Hello World" )
61+ .start (" Hello State" )
62+ .states ([injectstateBuilder ()
63+ .type (" inject" )
64+ .name (" Hello State" )
65+ .data ({
66+ " result" : " Hello World!"
67+ })
68+ .end (true )
69+ .build ()
70+ ])
71+ .build ());
7072```
7173
7274#### Load a file JSON/YAML to a Workflow instance
@@ -83,20 +85,22 @@ Where `source` is a JSON or a YAML string.
8385Having the following workflow instance:
8486
8587``` typescript
86- const workflow = workflowJsonBuilder ()
87- .id (" helloworld" )
88- .version (" 1.0" )
89- .name (" Hello World Workflow" )
90- .description (" Inject Hello World" )
91- .start (" Hello State" )
92- .states ([injectstateBuilder ()
93- .type (" inject" )
94- .name (" Hello State" )
95- .data ({
96- " result" : " Hello World!"
97- })
98- .end (true ).build ()])
99- .build ());
88+ const workflow = workflowBuilder ()
89+ .id (" helloworld" )
90+ .version (" 1.0" )
91+ .name (" Hello World Workflow" )
92+ .description (" Inject Hello World" )
93+ .start (" Hello State" )
94+ .states ([injectstateBuilder ()
95+ .type (" inject" )
96+ .name (" Hello State" )
97+ .data ({
98+ " result" : " Hello World!"
99+ })
100+ .end (true )
101+ .build ()
102+ ])
103+ .build ());
100104```
101105
102106You can convert it to its string representation in JSON or YAML format
@@ -114,12 +118,13 @@ by using the static methods `toJson` or `toYaml` respectively:
114118
115119The sdk provides a way to validate if a workflow object is compliant with the serverlessworkflow specification.
116120
117- ` validators ` provides a map of validation functions:
121+ ` WorkflowValidator ` class provides a validation method:
122+
123+ - ` validate(): boolean `
118124
119125``` typescript
120- const validate = validators .get (' WorkflowJson' );
121- const isValid = validate (workflow );
122- if (! isValid ) {
123- validate .errors .forEach (error => console .error (error .message ));
126+ const workflowValidator = new WorkflowValidator (workflow );
127+ if (! workflowValidator .validate ()) {
128+ workflowValidator .validationErrors .forEach (error => console .error (error .message ));
124129}
125130```
0 commit comments