Пример #1
0
        /// <summary>
        /// 表示一般验证框对象
        /// <param name="validType">验证类型</param>
        /// <param name="validMessage">不通过时提示信息</param>
        /// <param name="parameters">验证的参数</param>
        /// </summary>
        public static ValidBox New(string validType, string validMessage, params object[] parameters)
        {
            var box  = new ValidBox();
            var rule = ValidBox.GenerateRule(validType, validMessage, parameters);

            box.validRuleList.Add(rule);
            return(box);
        }
Пример #2
0
        /// <summary>
        /// 验证框合并操作
        /// 返回合并后的验证框
        /// </summary>
        /// <param name="box1">要合并的对象1</param>
        /// /// <param name="box2">要合并的对象2</param>
        /// <returns></returns>
        public static ValidBox Merge(ValidBox box1, ValidBox box2)
        {
            var box = new ValidBox();

            box.validRuleList.AddRange(box1.validRuleList);
            box.validRuleList.AddRange(box2.validRuleList);

            box.required        = box1.required ? box1.required : box2.required;
            box.requiredMessage = box1.required ? box1.requiredMessage : box2.requiredMessage;
            box.message         = string.IsNullOrEmpty(box1.message) ? box2.message : box1.message;
            return(box);
        }
Пример #3
0
 /// <summary>
 /// 转换为对应的ValidBox类型
 /// </summary>
 /// <returns></returns>
 public override ValidBox ToValidBox()
 {
     return(ValidBox.New(this.ValidType, this.ErrorMessage, this.Min, this.Max));
 }
Пример #4
0
 /// <summary>
 /// 生成验证框对象
 /// </summary>
 /// <returns></returns>
 public ValidBox ToValidBox()
 {
     return(ValidBox.New("length", this.ErrorMessage, this.MinimumLength, this.MaximumLength));
 }
Пример #5
0
 /// <summary>
 /// 转换为对应的ValidBox类型
 /// </summary>
 /// <returns></returns>
 public override ValidBox ToValidBox()
 {
     return(ValidBox.New(this.ValidType, this.ErrorMessage, this.RegexPattern));
 }
Пример #6
0
 /// <summary>
 /// 生成验证框对象
 /// </summary>
 /// <returns></returns>
 public ValidBox ToValidBox()
 {
     return(ValidBox.Request(this.ErrorMessage));
 }
Пример #7
0
 /// <summary>
 /// 转换为对应的ValidBox类型
 /// </summary>
 /// <returns></returns>
 public override ValidBox ToValidBox()
 {
     return(ValidBox.New(this.ValidType, this.ErrorMessage, this.TargetId));
 }
Пример #8
0
        /// <summary>
        /// 生成验证框
        /// </summary>
        /// <returns></returns>
        public override ValidBox ToValidBox()
        {
            var parameters = new object[] { this.Url }.Concat(this.TargetId).ToArray();

            return(ValidBox.New(this.ValidType, this.ErrorMessage, parameters));
        }