1
0
mirror of synced 2024-11-14 14:33:49 +00:00
Tapeti/Tapeti.DataAnnotations/DataAnnotationsPublishMiddleware.cs
Mark van Renswoude fed377992b [ci skip] Done with XML documentation for now
Made a few classes internal that were supposed to be
2019-08-15 11:26:55 +02:00

24 lines
677 B
C#

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