public virtual bool RemoveError(string propertyName, string errorId) { var error = new ValidationCustomError(propertyName, errorId, ""); if (!Errors.ContainsKey(propertyName) || !Errors[propertyName].Contains(error)) { return(false); } Errors[propertyName].Remove(error); if (Errors[propertyName].Count == 0) { Errors.Remove(propertyName); if (Errors.Count == 0) { LastPropertyValidated = null; // No errors. Good. } else { using (var p = Errors.GetEnumerator()) { p.MoveNext(); LastPropertyValidated = p.Current.Key; } } } NotifyErrorsChanged(propertyName); return(true); }
public virtual bool AddError(ValidationCustomError error, bool isWarning = false) { Debug.Assert(error != null); var propertyName = error.PropertyName; if (!Errors.ContainsKey(propertyName)) { Errors[propertyName] = new List <ValidationCustomError>(); } LastPropertyValidated = propertyName; if (!Errors[propertyName].Contains(error)) { if (isWarning) { Errors[propertyName].Add(error); } else { Errors[propertyName].Insert(0, error); } NotifyErrorsChanged(propertyName); return(true); } else { return(false); } }