/// <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); }
/// <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); }
/// <summary> /// 转换为对应的ValidBox类型 /// </summary> /// <returns></returns> public override ValidBox ToValidBox() { return(ValidBox.New(this.ValidType, this.ErrorMessage, this.Min, this.Max)); }
/// <summary> /// 生成验证框对象 /// </summary> /// <returns></returns> public ValidBox ToValidBox() { return(ValidBox.New("length", this.ErrorMessage, this.MinimumLength, this.MaximumLength)); }
/// <summary> /// 转换为对应的ValidBox类型 /// </summary> /// <returns></returns> public override ValidBox ToValidBox() { return(ValidBox.New(this.ValidType, this.ErrorMessage, this.RegexPattern)); }
/// <summary> /// 生成验证框对象 /// </summary> /// <returns></returns> public ValidBox ToValidBox() { return(ValidBox.Request(this.ErrorMessage)); }
/// <summary> /// 转换为对应的ValidBox类型 /// </summary> /// <returns></returns> public override ValidBox ToValidBox() { return(ValidBox.New(this.ValidType, this.ErrorMessage, this.TargetId)); }
/// <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)); }