/// <summary> /// 验证输入的长度 /// </summary> /// <param name="box">验证框</param> /// <param name="minLength">最小长度</param> /// <param name="maxLength">最大长度</param> /// <param name="errorMessage">提示信息</param> /// <returns></returns> public static ValidBox Length(this ValidBox box, int minLength, int maxLength, string errorMessage) { var newBox = new LengthAttribute(minLength, maxLength) { ErrorMessage = errorMessage }.ToValidBox(); return ValidBox.Merge(box, newBox); }
/// <summary> /// 验证输入的长度 /// </summary> /// <param name="box">验证框</param> /// <param name="minLength">最小长度</param> /// <param name="maxLength">最大长度</param> /// <returns></returns> public static ValidBox Length(this ValidBox box, int minLength, int maxLength) { var newBox = new LengthAttribute(minLength, maxLength).ToValidBox(); return ValidBox.Merge(box, newBox); }