Replies: 2 comments 2 replies
-
Replace Handle method in ValidationBehavior with this public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
{
if (!_validators.Any()) return await next();
var context = new ValidationContext<TRequest>(request);
var validationResults =
await Task.WhenAll(_validators.Select(v => v.ValidateAsync(context, cancellationToken)));
var failures = validationResults
.SelectMany(r => r.Errors)
.Where(f => f != null)
.ToList();
if (failures.Count != 0)
throw new ValidationException(failures);
return await next();
} |
Beta Was this translation helpful? Give feedback.
2 replies
-
refer to https://github.com/jbogard/MediatR/wiki/Migration-Guide-11.x-to-12.0 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Dear Sir.
Please help me how to fix errors in ValidationBehaviour when i update MediatR to version 11.0
Beta Was this translation helpful? Give feedback.
All reactions