예제 #1
0
        public override ValidationResult Validate(object value, CultureInfo cultureInfo)
        {
            if (value is null)
            {
                return(new ValidationResult(false, "Field is required."));
            }

            var @string = value.ToString();

            var success = decimal.TryParse(@string, out var @decimal);

            if (success == false)
            {
                return(new ValidationResult(false, "Field should be valid decimal."));
            }

            return(_balanceRange.IsIncluded(@decimal)
                ? ValidationResult.ValidResult
                : new ValidationResult(false, $"Field should be in range {_balanceRange}."));
        }
예제 #2
0
 public bool CanInitialize(decimal?balance)
 {
     return(balance.HasValue && _balanceRange.IsIncluded(balance.Value));
 }