public void ClearValidationErrors <T>(T instance) { ValidationDone?.Invoke(this, new ValidationErrorEventArgs() { Errors = new List <ValidationResult>(), ValidationType = GetValidationType <T>(instance) }); }
public bool Validate <T>(T instance) { List <ValidationResult> res = new List <ValidationResult>(); bool isValid = Validator.TryValidateObject(instance, new ValidationContext(instance), res, true); ValidationDone?.Invoke(this, new ValidationErrorEventArgs() { Errors = res, ValidationType = GetValidationType <T>(instance) }); return(isValid); }
public void NotifyAboutServerErrors <T>(T instance, ValidationErrors serverErrors) { List <ValidationResult> errors = new List <ValidationResult>(); foreach (string key in serverErrors.Errors.Keys) { foreach (string error in serverErrors.Errors[key]) { errors.Add(new ValidationResult(error, new string[] { key })); } } ValidationDone?.Invoke(this, new ValidationErrorEventArgs() { Errors = errors, ValidationType = GetValidationType <T>(instance) }); }