tangxu
2024-01-09 ddc2780231ea76be74fadb7486401a3d0d17b101
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
namespace Yw.Application.Health
{
    /// <summary>
    /// 自动评价
    /// </summary>
    public class AutoEvaluation : Model.JsonModel<AutoEvaluation>, IValidatableObject
    {
        /// <summary>
        /// 子项列表
        /// </summary>
        [Required]
        public List<AutoEvaluationItem> Items { get; set; }
 
        /// <summary>
        /// 
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            if (this.Items == null || this.Items.Count < 1)
            {
                yield return new ValidationResult(
                       "Items 不能为空"
                       , new[] { nameof(Items) }
                   );
            }
            else if (this.Items.Exists(x => x == null))
            {
                yield return new ValidationResult(
                       "Items 存在无效项"
                       , new[] { nameof(Items) }
                   );
            }
        }
    }
}