private void Validate(T entity) { var validator = new EntityValidator(); if (validator.IsValid(entity) == false) { throw new UcoinValidationException(validator.GetInvalidMessages()); } }
public void ThrowExceptionIfInvalid() { var validator = new EntityValidator(); if (!validator.IsValid(this)) { throw new CustomValidationException(validator.GetInvalidMessages()); } }
private void Validate(IEnumerable <T> entities) { var validator = new EntityValidator(); var errorList = new List <string>(); foreach (var e in entities) { if (validator.IsValid(e) == false) { errorList.AddRange(validator.GetInvalidMessages()); } } if (errorList.Any()) { throw new UcoinValidationException(errorList); } }