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