fix(dir): 🐛 support async ValidatorPipelineBehavior validations

This commit is contained in:
Collin M. Barrett 2021-11-13 05:54:04 -06:00
parent 0ad50629d5
commit 51feda8b79

View file

@ -13,15 +13,11 @@ public ValidatorPipelineBehavior(IEnumerable<IValidator<TRequest>> validators)
_validators = validators;
}
public Task<TResponse> Handle(TRequest request,
public async Task<TResponse> Handle(TRequest request,
CancellationToken cancellationToken,
RequestHandlerDelegate<TResponse> next)
{
foreach (var validator in _validators)
{
validator.ValidateAndThrow(request);
}
return next();
await Task.WhenAll(_validators.Select(v => v.ValidateAndThrowAsync(request, cancellationToken)));
return await next();
}
}