Skip to content

Commit

Permalink
Merge pull request #112 from JeffDownie/main
Browse files Browse the repository at this point in the history
fix: choice statements must have a Next in first level operators
  • Loading branch information
ChristopheBougere authored Sep 2, 2022
2 parents e5eee30 + 9e4874a commit 7eade83
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 6 deletions.
20 changes: 20 additions & 0 deletions src/__tests__/definitions/invalid-choice-state.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"Comment": "An example showing that choice states are not allowed to go directly to the end of state machine",
"StartAt": "ChoiceState",
"States": {
"ChoiceState": {
"Type": "Choice",
"Choices": [{
"Variable": "$.foo",
"NumericEquals": 1,
"End": true
}
],
"Default": "DefaultState"
},
"DefaultState": {
"Type": "Pass",
"End": true
}
}
}
9 changes: 7 additions & 2 deletions src/__tests__/definitions/valid-choice-state.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@
"Next": "FirstMatchState"
},
{
"Variable": "$.foo",
"NumericEquals": 2,
"Or": [{
"Variable": "$.foo",
"NumericEquals": 2
}, {
"Variable": "$.foo",
"NumericEquals": 3
}],
"Next": "SecondMatchState"
}
],
Expand Down
15 changes: 11 additions & 4 deletions src/schemas/choice.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"Variable": {
"type": "string"
},
"Next": {
"type": "string"
},
"And": {
"type": "array",
"items": {
Expand Down Expand Up @@ -297,7 +294,17 @@
"Choices": {
"type": "array",
"items": {
"$ref": "#/definitions/Operator"
"allOf": [{
"type": "object",
"properties": {
"Next": {
"type": "string"
}
},
"required": ["Next"]
}, {
"$ref": "#/definitions/Operator"
}]
}
},
"Default": {
Expand Down

0 comments on commit 7eade83

Please sign in to comment.