Files
Shrlalgo.RvKits/ShrlAlgoToolkit.RevitAddins/ValidationRules/UndefinedCharRules.cs

26 lines
779 B
C#
Raw Normal View History

2024-09-22 11:05:41 +08:00
using System.Globalization;
using System.Windows.Controls;
2025-04-24 20:56:44 +08:00
namespace ShrlAlgoToolkit.Mvvm.ValidationRules
2024-09-22 11:05:41 +08:00
{
public class UndefinedCharRules : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
char[] chars = new[] { '\\', ':', '{', '}', '[', ']', '|', ';', '<', '>', '?', '`', '~' };
if (value != null)
{
foreach (var c in chars)
{
if (value.ToString().IndexOf(c) > -1)
{
return new(false, $"名称不能包含字符:'\\ : [ ] | {{}}; < > ? ` ~");
}
}
}
return ValidationResult.ValidResult;
}
}
}