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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
namespace Yw.Application.Health
{
    /// <summary>
    /// 
    /// </summary>
    public class AutoEvaluationItem : IValidatableObject
    {
        /// <summary>
        /// 下限
        /// </summary>
        public double? MinValue { get; set; }
 
        /// <summary>
        /// 上限
        /// </summary>
        public double? MaxValue { get; set; }
 
        /// <summary>
        /// 表达式(计算表达式)
        /// </summary>
        [Required]
        public string Expression { get; set; }
 
 
        /// <summary>
        /// 
        /// </summary>
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
 
            if (string.IsNullOrEmpty(this.Expression))
            {
                yield return new ValidationResult(
                       "Expression 计算表达式不能为空"
                       , new[] { nameof(Expression) }
                   );
            }
 
            if (!DynamicExpresso.Validator.VerifyMax(this.Expression, 1))
            {
                yield return new ValidationResult(
                       "Expression 计算表达式配置错误"
                       , new[] { nameof(Expression) }
                   );
            }
 
 
        }
 
    }
 
}