This commit is contained in:
ShrlAlgo
2025-07-11 09:20:23 +08:00
parent c7b104f44f
commit 4d35cadb56
840 changed files with 102347 additions and 11595 deletions

View File

@@ -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]);
}
}