Mark van Renswoude
bcdb376256
Added test for publish overflows Removed support for Unity Container Changed third party package references to ranges Fixed XML documentation
23 lines
663 B
C#
23 lines
663 B
C#
using System;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.Threading.Tasks;
|
|
using Tapeti.Config;
|
|
|
|
namespace Tapeti.DataAnnotations
|
|
{
|
|
/// <summary>
|
|
/// Validates consumed messages using System.ComponentModel.DataAnnotations
|
|
/// </summary>
|
|
internal class DataAnnotationsMessageMiddleware : IMessageMiddleware
|
|
{
|
|
/// <inheritdoc />
|
|
public ValueTask Handle(IMessageContext context, Func<ValueTask> next)
|
|
{
|
|
var validationContext = new ValidationContext(context.Message);
|
|
Validator.ValidateObject(context.Message, validationContext, true);
|
|
|
|
return next();
|
|
}
|
|
}
|
|
}
|