mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-07-16 17:47:22 +00:00
Format ./web/backend/Shared/Shared.Application
This commit is contained in:
@@ -19,20 +19,20 @@ public class ValidationBehavior<TRequest, TResponse>(IEnumerable<IValidator<TReq
|
|||||||
CancellationToken cancellationToken
|
CancellationToken cancellationToken
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (!validators.Any()) return await next();
|
if (!validators.Any())
|
||||||
|
return await next();
|
||||||
|
|
||||||
ValidationContext<TRequest> context = new(request);
|
ValidationContext<TRequest> context = new(request);
|
||||||
|
|
||||||
List<ValidationFailure> failures = (
|
List<ValidationFailure> failures = (
|
||||||
await Task.WhenAll(
|
await Task.WhenAll(validators.Select(v => v.ValidateAsync(context, cancellationToken)))
|
||||||
validators.Select(v => v.ValidateAsync(context, cancellationToken))
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
.SelectMany(result => result.Errors)
|
.SelectMany(result => result.Errors)
|
||||||
.Where(failure => failure != null)
|
.Where(failure => failure != null)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
if (failures.Count > 0) throw new ValidationException(failures);
|
if (failures.Count > 0)
|
||||||
|
throw new ValidationException(failures);
|
||||||
|
|
||||||
return await next();
|
return await next();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,5 @@ namespace Shared.Application.Emails;
|
|||||||
/// Cross-slice command sent by Features.Auth and handled by Features.Emails to dispatch a
|
/// Cross-slice command sent by Features.Auth and handled by Features.Emails to dispatch a
|
||||||
/// registration confirmation email, without either slice taking a project reference on the other.
|
/// registration confirmation email, without either slice taking a project reference on the other.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public record SendRegistrationEmailCommand(
|
public record SendRegistrationEmailCommand(string FirstName, string Email, string ConfirmationToken)
|
||||||
string FirstName,
|
: IRequest;
|
||||||
string Email,
|
|
||||||
string ConfirmationToken
|
|
||||||
) : IRequest;
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="MediatR" Version="12.4.1"/>
|
<PackageReference Include="MediatR" Version="12.4.1" />
|
||||||
<PackageReference Include="FluentValidation" Version="11.3.0"/>
|
<PackageReference Include="FluentValidation" Version="11.3.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user