At.FF.Krems.Utils.WPF.ValidationRules.MaxMax2Int.Validate C# (CSharp) Method

Validate() public method

When overridden in a derived class, performs validation checks on a value.
public Validate ( object value, CultureInfo cultureInfo ) : System.Windows.Controls.ValidationResult
value object The value from the binding target to check.
cultureInfo System.Globalization.CultureInfo The culture to use in this rule.
return System.Windows.Controls.ValidationResult
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (string.IsNullOrEmpty((string)value))
            {
                return new ValidationResult(false, "String is null or empty.");
            }

            var valueString = ((string)value).ToLowerInvariant();
            int integer;
            var match = valueString == "max" || valueString == "max2" || int.TryParse(valueString, out integer);
            return new ValidationResult(match, match ? null : "Only max, max2 or integer allowed.");
        }
MaxMax2Int