Skip to content

Commit 0f53470

Browse files
merge pull request #4 from https-richardy/feature/02-implements-shipping-address-in-orchestrator
[#2] - implements shipping address in orchestrator
2 parents e073d6f + 2b474de commit 0f53470

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.Application/Comanda.Orchestrator.Application.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="FluentValidation" Version="12.1.1" />
1111
<PackageReference Include="HttpsRichardy.Dispatcher" Version="1.0.2" />
1212
<PackageReference Include="HttpsRichardy.Federation.Sdk.Contracts" Version="1.0.2" />
13-
<PackageReference Include="Comanda.Internal.Contracts" Version="1.0.1" />
13+
<PackageReference Include="Comanda.Internal.Contracts" Version="1.0.8" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

Boundaries/Comanda.Orchestrator/Source/Comanda.Orchestrator.Application/Validators/Orders/OrderCreationSchemeValidator.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ public OrderCreationSchemeValidator()
1212
.IsInEnum()
1313
.WithMessage("fulfillment must be a valid enum value.");
1414

15+
RuleFor(order => order.Address)
16+
.NotNull()
17+
.WithMessage("address must be provided when fulfillment is delivery.")
18+
.When(order => order.Fulfillment == Fulfillment.Delivery);
19+
1520
RuleFor(order => order.Priority)
1621
.IsInEnum()
1722
.WithMessage("priority must be a valid enum value.");
@@ -20,6 +25,31 @@ public OrderCreationSchemeValidator()
2025
.NotNull()
2126
.WithMessage("metadata must be provided.");
2227

28+
When(order => order.Fulfillment == Fulfillment.Delivery && order.Address is not null, () =>
29+
{
30+
RuleFor(order => order.Address!.Street)
31+
.NotEmpty()
32+
.WithMessage("The street field is required and cannot be empty.");
33+
34+
RuleFor(order => order.Address!.Number)
35+
.NotEmpty()
36+
.WithMessage("The number field is required and represents the street number of the address.");
37+
38+
RuleFor(order => order.Address!.City)
39+
.NotEmpty()
40+
.WithMessage("The city field is required and cannot be empty.");
41+
42+
RuleFor(order => order.Address!.State)
43+
.NotEmpty()
44+
.WithMessage("The state field is required and cannot be empty.");
45+
46+
RuleFor(order => order.Address!.ZipCode)
47+
.NotEmpty()
48+
.WithMessage("The zip code field is required.")
49+
.Matches(ExpressionPatterns.Cep)
50+
.WithMessage("The zip code is invalid. It must match the Brazilian postal code format.");
51+
});
52+
2353
When(order => order.Metadata is not null, () =>
2454
{
2555
RuleFor(order => order.Metadata!.MerchantId)

0 commit comments

Comments
 (0)