1
0
mirror of synced 2024-11-05 19:19:16 +00:00
Tapeti/Tapeti.DataAnnotations/DataAnnotationsMessageMiddleware.cs
Mark van Renswoude 6c32665c8a [ci skip] Refactored how consume result is handled
Reimplemented the exception strategy and logging
Much XML documentation, such wow
2019-08-14 12:20:53 +02:00

24 lines
674 B
C#

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