summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Helpers/ObrigatorioValidationRule.cs
blob: 45cc3b6264c8039e3864f669c80ee76b8c49ce02 (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
using System.Globalization;
using System.Windows.Controls;

namespace Gestor.Application.Helpers;

public class ObrigatorioValidationRule : ValidationRule
{
	public bool IsRequired { get; set; }

	public override ValidationResult Validate(object value, CultureInfo cultureInfo)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		if (!(value is string text))
		{
			return new ValidationResult(false, (object)"OBRIGATÓRIO");
		}
		if (text != null && IsRequired && string.IsNullOrWhiteSpace(text))
		{
			return new ValidationResult(false, (object)"OBRIGATÓRIO");
		}
		return ValidationResult.ValidResult;
	}
}