public Validation(object target, object[] scopes) { if (target == null) { throw new ArgumentNullException(nameof(target)); } Target = target; Outcome = new ValidationOutcome(); ScopeMatcher = CreateScopeMatcher(scopes); _asyncResults = new List <Promise>(); }
private ValidationOutcome GetOrCreateOutcome(string propertyName, bool create = false) { var errors = _errors.GetOrAdd(propertyName, _ => new List <object>()); lock (errors) { var outcome = errors.OfType <ValidationOutcome>().FirstOrDefault(); if (outcome == null && create) { outcome = new ValidationOutcome(); errors.Add(outcome); outcome.ErrorsChanged += (s, e) => RaiseErrorsChanged($"{propertyName}.{e.PropertyName}"); } return(outcome); } }
public ValidationException(ValidationOutcome outcome) : base(outcome.Error) { Outcome = outcome; }
public ValidationException(string message, ValidationOutcome outcome) : base(message) { Outcome = outcome; }