File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
src/ServerlessWorkflow.Sdk/Services/Validation Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments