Browse Source

CompleteOrderValidations are added

pull/2134/head
hsn 1 year ago
parent
commit
fe8528d855
2 changed files with 12 additions and 0 deletions
  1. +11
    -0
      src/Services/Ordering/Ordering.API/Application/Validations/CompleteOrderCommandValidator.cs
  2. +1
    -0
      src/Services/Ordering/Ordering.API/Program.cs

+ 11
- 0
src/Services/Ordering/Ordering.API/Application/Validations/CompleteOrderCommandValidator.cs View File

@ -0,0 +1,11 @@
namespace Microsoft.eShopOnContainers.Services.Ordering.API.Application.Validations;
public class CompleteOrderCommandValidator : AbstractValidator<CompleteOrderCommand>
{
public CompleteOrderCommandValidator(ILogger<CompleteOrderCommandValidator> logger)
{
RuleFor(order => order.OrderNumber).NotEmpty().WithMessage("No orderId found");
logger.LogTrace("INSTANCE CREATED - {ClassName}", GetType().Name);
}
}

+ 1
- 0
src/Services/Ordering/Ordering.API/Program.cs View File

@ -23,6 +23,7 @@ services.AddMediatR(cfg =>
// Register the command validators for the validator behavior (validators based on FluentValidation library)
services.AddSingleton<IValidator<CancelOrderCommand>, CancelOrderCommandValidator>();
services.AddSingleton<IValidator<CompleteOrderCommand>, CompleteOrderCommandValidator>();
services.AddSingleton<IValidator<CreateOrderCommand>, CreateOrderCommandValidator>();
services.AddSingleton<IValidator<IdentifiedCommand<CreateOrderCommand, bool>>, IdentifiedCommandValidator>();
services.AddSingleton<IValidator<ShipOrderCommand>, ShipOrderCommandValidator>();


Loading…
Cancel
Save