16 lines
555 B
C#
16 lines
555 B
C#
|
|
using System;
|
|||
|
|
using System.ComponentModel.DataAnnotations;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace Szmedi.RvKits.Attributes
|
|||
|
|
{
|
|||
|
|
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter)]
|
|||
|
|
public sealed class IsNumericAttribute : ValidationAttribute
|
|||
|
|
{
|
|||
|
|
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
|||
|
|
{
|
|||
|
|
return double.TryParse(value.ToString(), out double _) ? ValidationResult.Success : new("输入内容不是数值。");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|