2017-02-12 20:43:30 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Tapeti.Config;
|
|
|
|
|
|
|
|
|
|
namespace Tapeti.DataAnnotations
|
|
|
|
|
{
|
|
|
|
|
public class DataAnnotationsPublishMiddleware : IPublishMiddleware
|
|
|
|
|
{
|
|
|
|
|
public Task Handle(IPublishContext context, Func<Task> next)
|
|
|
|
|
{
|
|
|
|
|
var validationContext = new ValidationContext(context.Message);
|
2019-07-18 08:02:42 +00:00
|
|
|
|
Validator.ValidateObject(context.Message, validationContext, true);
|
2017-02-12 20:43:30 +00:00
|
|
|
|
|
|
|
|
|
return next();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|