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)
{
if (value is null)
{
return true;
}
return Enum.IsDefined(Type, value);
}
}