Skip to content

Commit 8b059cf

Browse files
authored
Merge pull request #45 from antmendoza/add-validation-readme
add validate section to readme
2 parents ef6071a + 292b2df commit 8b059cf

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Provides the Typescript API/SPI for the [Serverless Workflow Specification](http
66
With the SDK you can:
77
* Parse workflow JSON and YAML definitions
88
* (_WIP_) Programmatically build workflow definitions
9-
9+
* (_WIP_) Validate workflow definitions
1010

1111
## Getting Started
1212

@@ -107,5 +107,26 @@ by using the static methods `toJSON` or `toYAML` respectively:
107107
const workflowAsYAML = BaseWorkflow.toYAML(workflow);
108108
```
109109

110+
#### Validate workflow definitions
111+
112+
The sdk provides a way to validate if a workflow object is compliant with the serverlessworkflow specification.
113+
114+
`WorkflowValidator` class provides two methods:
115+
116+
- `isValid(): boolean`
117+
118+
```typescript
119+
120+
const isValid = new WorkflowValidator(workflow).isValid();
121+
122+
```
123+
124+
- `validate(): ValidationErrors`
110125

126+
```typescript
111127

128+
const validationErrors = new WorkflowValidator(workflow).validate();
129+
validationErrors.errors().forEach(error => console.error(error.message()))
130+
131+
132+
```

0 commit comments

Comments
 (0)