| using System; | 
| using System.Collections.Generic; | 
| using System.Linq; | 
| using System.Text; | 
| using System.Threading.Tasks; | 
|   | 
| namespace WIDESEA_Core.Attributes | 
| { | 
|     [AttributeUsage(AttributeTargets.Property)] | 
|     public class PropertyValidateAttribute : Attribute | 
|     { | 
|         /// <summary> | 
|         /// 最大值 | 
|         /// </summary> | 
|         public int MaxValue { get; set; } = int.MaxValue; | 
|   | 
|         /// <summary> | 
|         /// 最小值 | 
|         /// </summary> | 
|         public int MinValue { get; set; } = int.MinValue; | 
|   | 
|         /// <summary> | 
|         /// 非空 | 
|         /// </summary> | 
|         public bool NotNullAndEmpty { get; set; } = true; | 
|   | 
|         /// <summary> | 
|         /// 是否包含最大值 | 
|         /// </summary> | 
|         public bool IsContainMaxValue { get; set; } = false; | 
|   | 
|         /// <summary> | 
|         /// 是否包含最小值 | 
|         /// </summary> | 
|         public bool IsContainMinValue { get; set; } = false; | 
|   | 
|         /// <summary> | 
|         /// 根据其他属性非空判断当前是否为非空 | 
|         /// </summary> | 
|         public string NotNullAndEmptyWithProperty { get; set; } | 
|   | 
|         /// <summary> | 
|         /// 根据其他属性值判断当前是否为非空(格式【new string[]{ "属性名称", "属性值" }】) | 
|         /// </summary> | 
|         public string[] NotNullAndEmptyWithPropertyAndValue { get; set; } | 
|   | 
|         /// <summary> | 
|         /// 说明 | 
|         /// </summary> | 
|         public string Description { get; set; } | 
|   | 
|         /// <summary> | 
|         /// 检查约束,属性值只允许是数组中的值 | 
|         /// </summary> | 
|         public object[] Check { get; set; } | 
|   | 
|         /// <summary> | 
|         /// 以...开头 | 
|         /// </summary> | 
|         public string StartWith { get; set; } | 
|   | 
|         /// <summary> | 
|         /// 以...结尾 | 
|         /// </summary> | 
|         public string EndWith { get; set; } | 
|   | 
|         /// <summary> | 
|         /// 最小长度 | 
|         /// </summary> | 
|         public int MinLength { get; set; } = 0; | 
|   | 
|         /// <summary> | 
|         /// 最大长度 | 
|         /// </summary> | 
|         public int MaxLength { get; set; } = int.MaxValue; | 
|   | 
|         public PropertyValidateAttribute(string description) | 
|         { | 
|             if (!string.IsNullOrEmpty(description)) | 
|                 Description = description; | 
|         } | 
|     } | 
|   | 
|     [AttributeUsage(AttributeTargets.Class)] | 
|     public class ModelValidateAttribute : Attribute | 
|     { | 
|         public ModelValidateType ModelValidateType { get; } = ModelValidateType.SimpleValidate; | 
|   | 
|         public Func<object, (bool, string, object?)> CustomValidateMethod { get; set; } | 
|   | 
|         public object ErrorResponse { get; set; } | 
|   | 
|         public ModelValidateAttribute() | 
|         { | 
|         } | 
|   | 
|         public ModelValidateAttribute(Func<object, (bool, string, object?)> customValidateMethod) | 
|         { | 
|             CustomValidateMethod = customValidateMethod; | 
|         } | 
|     } | 
|   | 
|     public enum ModelValidateType | 
|     { | 
|         SimpleValidate, | 
|         CustomValidate, | 
|         SimpleAndCustom | 
|     } | 
| } |