public static Result Validate(Action <GenericValidator <T> > configureAction, T entity) { var validator = new GenericValidator <T>(); configureAction(validator); return(validator.GetValidationResult(entity)); }
public Task <Result> Send(string templateId, string recipientAddress, DataWithCompanyInfo messageData) { return(Validate() .Bind(SendEmail)); Result Validate() { return(GenericValidator <string> .Validate(v => { v.RuleFor(e => e).NotEmpty().EmailAddress(); }, recipientAddress)); } Task <Result> SendEmail() => Send(templateId, new[] { recipientAddress }, messageData); }