Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment nested choice rule #66

Merged
merged 2 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions data/StateMachine.j2119
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ A Nested Rule with an "Or" field is a "Nested Boolean".
A Nested Rule with a "Not" field is a "Nested Boolean".
A Nested Rule MUST NOT have a field named "Next".
A Nested Rule MAY have a field named "Variable".
A Nested Rule MAY have a string field named "Comment".
A Nested Rule with a "Variable" field is a "Nested Comparison".
A Nested Comparison MAY have a string field named "StringEquals".
A Nested Comparison MAY have a string field named "StringLessThan".
Expand Down
7 changes: 7 additions & 0 deletions spec/statelint_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -436,4 +436,11 @@
problems = linter.validate(j)
expect(problems.size).to eq(1)
end

it 'should allow Comment in Nested Choice Rules' do
j = File.read "test/choice-nested-comment.json"
linter = StateMachineLint::Linter.new
problems = linter.validate(j)
expect(problems.size).to eq(0)
end
end
2 changes: 1 addition & 1 deletion statelint.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'statelint'
s.version = '0.7.0'
s.version = '0.8.0'
s.summary = "State Machine JSON validator"
s.description = "Validates a JSON object representing a State Machine"
s.authors = ["Tim Bray"]
Expand Down
65 changes: 65 additions & 0 deletions test/choice-nested-comment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"Comment": "A workflow definition with Comment fields at multiple levels in a Choice state",
"StartAt": "Choice",
"States": {
"Choice": {
"Type": "Choice",
"Choices": [
{
"Variable": "$.a",
"IsPresent": true,
"Next": "Choice-Nested",
"Comment": "my comment"
}
],
"Default": "Decision3"
},
"Choice-Nested": {
"Type": "Choice",
"Choices": [
{
"And": [
{
"Variable": "$.b",
"IsPresent": true,
"Comment": "nested comment"
},
{
"Variable": "$.c",
"IsPresent": true
},
{
"Or": [
{
"Variable": "$.d",
"IsPresent": true,
"Comment": "nested comment"
},
{
"Variable": "$.e",
"IsPresent": true
}
],
"Comment": "nested comment in Or"
}
],
"Comment": "nested choice",
"Next": "Decision1"
}
],
"Default": "Decision2"
},
"Decision1": {
"Type": "Pass",
"End": true
},
"Decision2": {
"Type": "Pass",
"End": true
},
"Decision3": {
"Type": "Pass",
"End": true
}
}
}
Loading