ningshuxia
2024-01-10 fbf4a1e607460d256c2aa6ae32ee7be0da5248f2
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
namespace IStation.Application
{
    /// <summary>
    /// 
    /// </summary>
    public class ChenHangInput : IValidatableObject
    {
 
        /// <summary>
        /// 名称
        /// </summary>    
        [Required]
        public string Name { get; set; }
 
        /// <summary>
        /// 扣分
        /// </summary>
        public int Deduction { get; set; }
 
        /// <summary>
        /// 排序码
        /// </summary>
        [Required, Range(0, double.MaxValue, ErrorMessage = "SortCode 不能为负数")]
        public int SortCode { get; set; }
 
        /// <summary>
        /// 上限
        /// </summary>
        [Required, Range(0, double.MaxValue, ErrorMessage = "MaxValue 不能为负数")]
        public int MaxValue { get; set; }
 
        /// <summary>
        /// 说明
        /// </summary>    
        public string Description { get; set; }
 
 
 
        /// <summary>
        /// 
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (SortCode < 0)
            {
                yield return new ValidationResult(
                        "SortCode 不能为负数"
                        , new[] { nameof(SortCode) }
                    );
 
            }
        }
 
    }
}