using System; using System.ComponentModel.DataAnnotations; namespace Masuit.Tools.Core.Validator; /// /// 枚举值校验 /// public class EnumOfAttribute : ValidationAttribute { private Type Type { get; set; } /// /// 枚举类型 /// /// public EnumOfAttribute(Type value) { Type = value; } public override bool IsValid(object value) { return value is null || Enum.IsDefined(Type, value); } } /// /// 非空值校验 /// public class NotNullOrEmptyAttribute : ValidationAttribute { public override bool IsValid(object value) { return value is not null && !value.IsNullOrEmpty(); } }