1
1
using BuildingBlocks . Domain . Nodes . Node . Dtos ;
2
2
using BuildingBlocks . Domain . Nodes . Node . ValueObjects ;
3
+ using BuildingBlocks . Domain . Timelines . Timeline . ValueObjects ;
3
4
4
5
namespace Nodes . Application . Entities . Nodes . Commands . CreateNode ;
5
6
6
7
// ReSharper disable once ClassNeverInstantiated.Global
7
- public record CreateNodeCommand ( NodeDto Node ) : ICommand < CreateNodeResult > ;
8
+ public record CreateNodeCommand : ICommand < CreateNodeResult >
9
+ {
10
+ public required string Title { get ; set ; }
11
+ public required string Description { get ; set ; }
12
+ public required string Phase { get ; set ; }
13
+ public required DateTime Timestamp { get ; set ; }
14
+ public required int Importance { get ; set ; }
15
+ public required List < string > Categories { get ; set ; }
16
+ public required List < string > Tags { get ; set ; }
17
+ public required TimelineId TimelineId { get ; set ; }
18
+ }
8
19
9
20
// ReSharper disable once NotAccessedPositionalProperty.Global
10
21
public record CreateNodeResult ( NodeId Id ) ;
@@ -13,40 +24,40 @@ public class CreateNodeCommandValidator : AbstractValidator<CreateNodeCommand>
13
24
{
14
25
public CreateNodeCommandValidator ( )
15
26
{
16
- RuleFor ( x => x . Node . Title )
27
+ RuleFor ( x => x . Title )
17
28
. NotEmpty ( ) . WithMessage ( "Title is required." )
18
29
. MaximumLength ( 100 ) . WithMessage ( "Title must not exceed 100 characters." ) ;
19
30
20
- RuleFor ( x => x . Node . Description )
31
+ RuleFor ( x => x . Description )
21
32
. NotEmpty ( ) . WithMessage ( "Description is required." )
22
33
. MaximumLength ( 500 ) . WithMessage ( "Description must not exceed 500 characters." ) ;
23
34
24
- RuleFor ( x => x . Node . Timestamp )
35
+ RuleFor ( x => x . Timestamp )
25
36
. LessThanOrEqualTo ( DateTime . Now ) . WithMessage ( "Timestamp cannot be in the future." ) ;
26
37
27
- RuleFor ( x => x . Node . Importance )
38
+ RuleFor ( x => x . Importance )
28
39
. InclusiveBetween ( 1 , 10 ) . WithMessage ( "Importance must be between 1 and 10." ) ;
29
40
30
- RuleFor ( x => x . Node . Phase )
41
+ RuleFor ( x => x . Phase )
31
42
. NotEmpty ( ) . WithMessage ( "Phase is required." ) ;
32
43
33
- RuleFor ( x => x . Node )
44
+ RuleFor ( x => x )
34
45
. NotNull ( ) . WithMessage ( "Node cannot be null." )
35
46
. DependentRules ( ( ) =>
36
47
{
37
- RuleFor ( x => x . Node . Categories )
48
+ RuleFor ( x => x . Categories )
38
49
. Must ( categories => categories != null && categories . Count > 0 )
39
50
. WithMessage ( "At least one category must be provided." ) ;
40
51
41
- RuleFor ( x => x . Node . Tags )
52
+ RuleFor ( x => x . Tags )
42
53
. Must ( tags => tags != null && tags . Count > 0 )
43
54
. WithMessage ( "At least one tag must be provided." ) ;
44
55
} ) ;
45
56
46
- RuleForEach ( x => x . Node . Categories )
57
+ RuleForEach ( x => x . Categories )
47
58
. MaximumLength ( 50 ) . WithMessage ( "Category must not exceed 50 characters." ) ;
48
59
49
- RuleForEach ( x => x . Node . Tags )
60
+ RuleForEach ( x => x . Tags )
50
61
. MaximumLength ( 50 ) . WithMessage ( "Tag must not exceed 50 characters." ) ;
51
62
}
52
63
}
0 commit comments