1
0
mirror of synced 2024-11-05 02:59:16 +00:00
Tapeti/Tapeti.DataAnnotations/DataAnnotationsPublishMiddleware.cs
2019-07-18 10:03:01 +02:00

19 lines
507 B
C#

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);
Validator.ValidateObject(context.Message, validationContext, true);
return next();
}
}
}