23 lines
619 B
C#
23 lines
619 B
C#
using System.Globalization;
|
|
using System.Windows.Controls;
|
|
|
|
namespace ENI2.Util
|
|
{
|
|
public class RequiredStringValidationRule : ValidationRule
|
|
{
|
|
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
|
{
|
|
if (value == null)
|
|
return new ValidationResult(false, "Value is required");
|
|
|
|
if (value is string text)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(text))
|
|
return new ValidationResult(false, "Value is required");
|
|
}
|
|
|
|
return ValidationResult.ValidResult;
|
|
}
|
|
}
|
|
}
|