更新
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
|
||||
namespace ShrlAlgoToolkit.Mvvm.Attributes;
|
||||
|
||||
@@ -9,4 +10,12 @@ public sealed class IsNumericAttribute : ValidationAttribute
|
||||
{
|
||||
return double.TryParse(value.ToString(), out var _) ? ValidationResult.Success : new("输入内容不是数值。");
|
||||
}
|
||||
public override bool IsValid(object value)
|
||||
{
|
||||
return double.TryParse(value.ToString(), out var _);
|
||||
}
|
||||
public override string FormatErrorMessage(string name)
|
||||
{
|
||||
return string.Format(CultureInfo.CurrentCulture, base.ErrorMessageString, [name]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user