2017-02-12 21:43:30 +01: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 10:02:42 +02:00
|
|
|
|
Validator.ValidateObject(context.Message, validationContext, true);
|
2017-02-12 21:43:30 +01:00
|
|
|
|
|
|
|
|
|
return next();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|