Mark van Renswoude
6c32665c8a
Reimplemented the exception strategy and logging Much XML documentation, such wow
24 lines
675 B
C#
24 lines
675 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>
|
|
public 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();
|
|
}
|
|
}
|
|
}
|