示例#1
0
        public static Result Validate(Action <GenericValidator <T> > configureAction, T entity)
        {
            var validator = new GenericValidator <T>();

            configureAction(validator);
            return(validator.GetValidationResult(entity));
        }
示例#2
0
        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);
        }