using System; using System.ComponentModel.DataAnnotations; namespace Masuit.Tools.Core.Validator; /// /// 最小值校验 /// public class MinValueAttribute : ValidationAttribute { private double MinValue { get; set; } /// /// 最小值 /// /// public MinValueAttribute(double value) { MinValue = value; } /// /// 最小值校验 /// /// /// public override bool IsValid(object value) { if (value is null) { return true; } var input = Convert.ToDouble(value); return input > MinValue; } /// Applies formatting to an error message, based on the data field where the error occurred. /// The name to include in the formatted message. /// An instance of the formatted error message. public override string FormatErrorMessage(string name) { return base.FormatErrorMessage(name); } }