blob: ff5dc58e25bf7b2637a98d49704100cdd0fd72b5 (
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
31
32
33
34
|
using System;
using System.Globalization;
using System.Runtime.CompilerServices;
using System.Windows.Controls;
namespace Gestor.Application.Helpers
{
public class ObrigatorioValidationRule : ValidationRule
{
public bool IsRequired
{
get;
set;
}
public ObrigatorioValidationRule()
{
}
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
string str = value as string;
if (str == null)
{
return new ValidationResult(false, "OBRIGATÓRIO");
}
if (str == null || !this.IsRequired || !string.IsNullOrWhiteSpace(str))
{
return ValidationResult.ValidResult;
}
return new ValidationResult(false, "OBRIGATÓRIO");
}
}
}
|