Exemplo n.º 1
0
        public override ValidResult ValidInputs(string[] value)
        {
            var data = new ValidResult();

            if (!ValidateHelper.IsPlumpList(this.Normal))
            {
                data.ValidErrors.Add("没有设置正常选项,无法验证输入");
                return(data);
            }
            var list = ConvertHelper.NotNullList(value);

            if (list.AllEqual(this.Normal))
            {
                data.Tips.AddRange(this.EqualTips ?? new List <string>());
            }
            else
            {
                if (list.AnyEqual(this.Normal))
                {
                    data.Tips.AddRange(this.AnyEqualTips ?? new List <string>());
                }
                else
                {
                    data.Tips.AddRange(this.NotEqualTips ?? new List <string>());
                }
            }

            return(data);
        }
Exemplo n.º 2
0
        public override ValidResult ValidInputs(bool value)
        {
            var data = new ValidResult();

            if (value == this.Normal)
            {
                data.Tips.AddWhenNotEmpty(this.EqualTips ?? new List <string>());
            }
            else
            {
                data.Tips.AddWhenNotEmpty(this.NotEqualTips ?? new List <string>());
            }

            return(data);
        }
Exemplo n.º 3
0
        public override ValidResult ValidInputs(double value)
        {
            var data = new ValidResult();

            if (this.Range == null || this.Range.Length != 2)
            {
                data.ValidErrors.Add("设备没有设置误差范围,无法验证提交数据");
                return(data);
            }

            if (value < this.Normal * Range[0])
            {
                data.Tips.AddRange(this.LowerTips ?? new List <string>());
            }
            if (value > this.Normal * Range[1])
            {
                data.Tips.AddRange(this.UpperTips ?? new List <string>());
            }

            return(data);
        }
Exemplo n.º 4
0
        public override ValidResult ValidInputs(double value)
        {
            var data = new ValidResult();

            if (this.Range?.Length != 2)
            {
                data.ValidErrors.Add("设备没有设置误差范围,无法验证提交数据");
                return(data);
            }

            if (value < this.Normal * (1.00 - (Range[0] / 100.00)))
            {
                data.Tips.AddWhenNotEmpty(this.LowerTips ?? new List <string>());
            }
            if (value > this.Normal * (1.00 + (Range[1] / 100.00)))
            {
                data.Tips.AddWhenNotEmpty(this.UpperTips ?? new List <string>());
            }

            return(data);
        }