public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var errors = new List <BusinessValidationResult>();

            foreach (var rule in _validationRules)
            {
                errors.AddRange(BusinessValidationHelper.ExecuteValidationRule(rule, this));
            }

            if (errors.Any())
            {
                foreach (var error in errors)
                {
                    yield return(new ValidationResult(error.Message, new string[] { error.Property }));
                }
            }
            else
            {
                yield break;
            }
        }
Пример #2
0
 public void AddModelError(string message, Expression <Func <T, object> > property)
 {
     ValidationResult.Add(new BusinessValidationResult(message, BusinessValidationHelper.GetPropertyName <T>(property)));
 }