using System;
using System.ComponentModel.DataAnnotations;
using System.Threading.Tasks;
using Tapeti.Config;
namespace Tapeti.DataAnnotations
{
///
///
/// Validates published messages using System.ComponentModel.DataAnnotations
///
internal class DataAnnotationsPublishMiddleware : IPublishMiddleware
{
///
public async Task Handle(IPublishContext context, Func next)
{
var validationContext = new ValidationContext(context.Message);
Validator.ValidateObject(context.Message, validationContext, true);
await next();
}
}
}