14 lines
554 B
C#
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("输入内容不是数值。");
|
|
}
|
|
}
|