blob: aac00fdf1b0208757903f0dd8096621b69b8bc6b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
namespace Tango.MachineStudio.Common.ValidationRules
{
/// <summary>
/// Represents a required field validation rule.
/// </summary>
/// <seealso cref="System.Windows.Controls.ValidationRule" />
public class Required : ValidationRule
{
/// <summary>
/// When overridden in a derived class, performs validation checks on a value.
/// </summary>
/// <param name="value">The value from the binding target to check.</param>
/// <param name="cultureInfo">The culture to use in this rule.</param>
/// <returns>
/// A <see cref="T:System.Windows.Controls.ValidationResult" /> object.
/// </returns>
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
return new ValidationResult(!String.IsNullOrWhiteSpace(value.ToStringSafe()), "Required");
}
}
}
|