-
Notifications
You must be signed in to change notification settings - Fork 8
/
Config.cs
116 lines (90 loc) · 3.81 KB
/
Config.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
using FluentValidation;
using Headway.Core.Attributes;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace Headway.Core.Model
{
[DynamicModel]
public class Config : ModelBase
{
public Config()
{
ConfigItems = new List<ConfigItem>();
ConfigContainers = new List<ConfigContainer>();
ConfigSearchItems = new List<ConfigSearchItem>();
}
public int ConfigId { get; set; }
public int? FlowId { get; set; }
public bool NavigateResetBreadcrumb { get; set; }
public bool CreateLocal { get; set; }
public bool UseSearchComponent { get; set; }
public List<ConfigItem> ConfigItems { get; set; }
public List<ConfigContainer> ConfigContainers { get; set; }
public List<ConfigSearchItem> ConfigSearchItems { get; set; }
public Flow Flow { get; set; }
[Required]
[StringLength(50)]
public string Name { get; set; }
[Required]
[StringLength(50)]
public string Title { get; set; }
[Required]
[StringLength(150)]
public string Description { get; set; }
[Required]
[StringLength(150)]
public string Model { get; set; }
[Required]
[StringLength(50)]
public string ModelApi { get; set; }
[StringLength(50)]
public string OrderModelBy { get; set; }
[StringLength(150)]
public string Document { get; set; }
[StringLength(350)]
public string DocumentArgs { get; set; }
[StringLength(50)]
public string NavigatePage { get; set; }
[StringLength(50)]
public string NavigateProperty { get; set; }
[StringLength(50)]
public string NavigateConfig { get; set; }
[StringLength(150)]
public string SearchComponent { get; set; }
}
public class ConfigValidator : AbstractValidator<Config>
{
public ConfigValidator()
{
RuleFor(v => v.Name)
.NotNull().WithMessage("Name is required")
.Length(1, 50).WithMessage("Name cannot exceed 50 characters");
RuleFor(v => v.Title)
.NotNull().WithMessage("Title is required")
.Length(1, 50).WithMessage("Title cannot exceed 50 characters");
RuleFor(v => v.Description)
.NotNull().WithMessage("Description is required")
.Length(1, 150).WithMessage("Description cannot exceed 150 characters");
RuleFor(v => v.Model)
.NotNull().WithMessage("Model is required")
.Length(1, 150).WithMessage("Model cannot exceed 150 characters");
RuleFor(v => v.ModelApi)
.NotNull().WithMessage("Model Api is required")
.Length(1, 50).WithMessage("Model Api cannot exceed 50 characters");
RuleFor(v => v.OrderModelBy)
.Length(1, 50).WithMessage("Order Model By cannot exceed 50 characters");
RuleFor(v => v.Document)
.Length(1, 150).WithMessage("Document cannot exceed 150 characters");
RuleFor(v => v.DocumentArgs)
.Length(1, 350).WithMessage("Document Args cannot exceed 350 characters");
RuleFor(v => v.NavigatePage)
.Length(1, 150).WithMessage("Navigate Page cannot exceed 150 characters");
RuleFor(v => v.NavigateProperty)
.Length(1, 50).WithMessage("Navigate Property cannot exceed 50 characters");
RuleFor(v => v.NavigateConfig)
.Length(1, 50).WithMessage("Navigate Config cannot exceed 50 characters");
RuleFor(v => v.SearchComponent)
.Length(1, 150).WithMessage("Search Component cannot exceed 150 characters");
}
}
}