Skip to content

Commit 960b205

Browse files
committed
Add the SubflowReference property to the ActionDefinition
Signed-off-by: charles.davernas <[email protected]>
1 parent 8a21b9d commit 960b205

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using FluentValidation;
2+
using ServerlessWorkflow.Sdk.Models;
3+
using System.Linq;
4+
5+
namespace ServerlessWorkflow.Sdk.Services.Validation
6+
{
7+
/// <summary>
8+
/// Represents a service used to validate <see cref="ForEachStateDefinition"/>s
9+
/// </summary>
10+
public class ForEachStateValidator
11+
: StateDefinitionValidator<ForEachStateDefinition>
12+
{
13+
14+
/// <summary>
15+
/// Initializes a new <see cref="ForEachStateValidator"/>
16+
/// </summary>
17+
/// <param name="workflow">The <see cref="WorkflowDefinition"/> to validate</param>
18+
public ForEachStateValidator(WorkflowDefinition workflow)
19+
: base(workflow)
20+
{
21+
this.RuleFor(s => s.Actions)
22+
.NotEmpty()
23+
.WithErrorCode($"{nameof(ForEachStateDefinition)}.{nameof(ForEachStateDefinition.Actions)}");
24+
this.RuleForEach(s => s.Actions)
25+
.SetValidator(new ActionDefinitionValidator(this.Workflow))
26+
.When(s => s.Actions != null && s.Actions.Any())
27+
.WithErrorCode($"{nameof(ForEachStateDefinition)}.{nameof(ForEachStateDefinition.Actions)}");
28+
}
29+
30+
}
31+
32+
}

0 commit comments

Comments
 (0)