Files
2026-02-24 11:34:18 +08:00

14 lines
554 B
C#

using System.ComponentModel.DataAnnotations;
namespace ShrlAlgoToolkit.RevitAddins.Common.Attributes;
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
public sealed class NotNullOrEmptyAttribute : ValidationAttribute
{
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
{
var b = value != null || (value is string str && !string.IsNullOrEmpty(str));
return b ? ValidationResult.Success : new("输入内容不是数值。");
}
}