Skip to content

Commit

Permalink
Add example for noValidate option
Browse files Browse the repository at this point in the history
  • Loading branch information
nibble-4bits committed Sep 16, 2023
1 parent 91ec097 commit b4b6d52
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
4 changes: 3 additions & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Here you can find some useful examples demonstrating specific usages of AWS Loca
- [check-for-execution-failure](./check-for-execution-failure.js): Check if execution failed and catch error.
- [check-for-execution-timeout](./check-for-execution-timeout.js): Check if execution timed out because the execution ran longer than the seconds specified in the `TimeoutSeconds` field and catch error.
- [custom-context-object](./custom-context-object.js): Pass a mock Context Object to the execution.
- [disable-state-machine-validation](./disable-state-machine-validation.js): Disable ARN and/or JSONPath validations when instantiating a new `StateMachine` object.
- [disable-arn-validation](./disable-arn-validation.js): Disable ARN validation when instantiating a new `StateMachine` object.
- [disable-jsonpath-validation](./disable-jsonpath-validation.js): Disable JSONPath validation when instantiating a new `StateMachine` object.
- [disable-state-machine-validation](./disable-state-machine-validation.js): Completely disable validation of the state machine definition when instantiating a new `StateMachine` object.
- [execution-event-logs](./execution-event-logs.js): Pulling the log of events produced by an execution as it runs and printing them.
- [task-state-local-override](./task-state-local-override.js): Override the default action for a `Task` state, so that instead of invoking the Lambda specified in the `Resource` field, it runs a local function. This allows running state machines completely locally.
- [wait-state-local-override](./wait-state-local-override.js): Override the wait duration of a `Wait` state so that instead of waiting the duration specified in the `Seconds`, `Timestamp`, `SecondsPath`, `TimestampPath` fields, it waits for a specified number of milliseconds.
24 changes: 24 additions & 0 deletions examples/disable-arn-validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { StateMachine } from 'aws-local-stepfunctions';

const machineDefinition = {
Comment: 'A simple minimal example of the States language',
StartAt: 'Hello World',
States: {
'Hello World': {
Type: 'Task',
InputPath: '$.data',
Resource: 'invalid arn syntax',
End: true,
},
},
};

// Construct a new state machine with the given definition and don't validate ARNs
const stateMachine = new StateMachine(machineDefinition, {
validationOptions: {
checkArn: false,
},
});

// The following log is printed because no error was thrown by the constructor
console.log('No error was thrown!');
24 changes: 24 additions & 0 deletions examples/disable-jsonpath-validation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { StateMachine } from 'aws-local-stepfunctions';

const machineDefinition = {
Comment: 'A simple minimal example of the States language',
StartAt: 'Hello World',
States: {
'Hello World': {
Type: 'Task',
InputPath: 'invalid JSONPath syntax',
Resource: 'arn:aws:lambda:us-east-1:123456789012:function:AddNumbers',
End: true,
},
},
};

// Construct a new state machine with the given definition and don't validate JSONPaths
const stateMachine = new StateMachine(machineDefinition, {
validationOptions: {
checkPaths: false,
},
});

// The following log is printed because no error was thrown by the constructor
console.log('No error was thrown!');
15 changes: 10 additions & 5 deletions examples/disable-state-machine-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,23 @@ const machineDefinition = {
States: {
'Hello World': {
Type: 'Task',
InputPath: 'invalid JSONPath syntax',
Resource: 'invalid arn syntax',
Resource: 'arn:aws:lambda:us-east-1:123456789012:function:AddNumbers',
End: true,
},
UnreachableState: {
Type: 'Succeed',
},
InvalidStateType: {
Type: 'SomeNewType',
},
},
InvalidTopLevelField: {},
};

// Construct a new state machine with the given definition and don't validate ARNs nor JSONPaths
// Construct a new state machine with the given definition and don't validate it at all
const stateMachine = new StateMachine(machineDefinition, {
validationOptions: {
checkArn: false,
checkPaths: false,
noValidate: true,
},
});

Expand Down

0 comments on commit b4b6d52

Please sign in to comment.