-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add create product command validatior
- Loading branch information
1 parent
b390a92
commit daae58d
Showing
18 changed files
with
90 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16980846711034705 | ||
17088716062710207 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
using FluentValidation; | ||
using MediatR; | ||
|
||
namespace Product.Application.Product.Commands; | ||
|
||
public sealed class CreateProductCommandHandler : IRequestHandler<CreateProductCommand> | ||
{ | ||
public Task Handle(CreateProductCommand request, CancellationToken cancellationToken) | ||
private readonly IValidator<CreateProductCommand> _validator; | ||
public CreateProductCommandHandler(IValidator<CreateProductCommand> validator) | ||
{ | ||
_validator = validator; | ||
} | ||
public Task Handle(CreateProductCommand command, CancellationToken cancellationToken) | ||
{ | ||
_validator.ValidateAndThrow(command); | ||
throw new NotImplementedException(); | ||
} | ||
} |
24 changes: 22 additions & 2 deletions
24
Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,26 @@ | ||
using FluentValidation; | ||
|
||
namespace Product.Application.Product.Commands; | ||
|
||
public class CreateProductCommandValidator | ||
public class CreateProductCommandValidator : AbstractValidator<CreateProductCommand> | ||
{ | ||
|
||
public CreateProductCommandValidator() | ||
{ | ||
|
||
RuleFor(command => command.Title) | ||
.NotEmpty() | ||
.NotNull() | ||
.WithMessage("The title can't be empty."); | ||
|
||
RuleFor(command => command.Description) | ||
.NotEmpty() | ||
.NotNull() | ||
.WithMessage("The description can't be empty."); | ||
|
||
RuleFor(command => command.CategoryId) | ||
.NotEqual(0) | ||
.NotEmpty() | ||
.NotNull() | ||
.WithMessage("The category identifier can't be empty."); | ||
} | ||
} |
Binary file modified
BIN
+459 Bytes
(120%)
Src/Product.Application/obj/Debug/net7.0/Product.Application.assets.cache
Binary file not shown.
Binary file modified
BIN
+432 Bytes
(100%)
Src/Product.Application/obj/Debug/net7.0/Product.Application.csproj.AssemblyReference.cache
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
"restore":{"projectUniqueName":"/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj","projectName":"Product.Application","projectPath":"/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj","outputPath":"/Users/macbook/Projects/ProductService/Src/Product.Application/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net7.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net7.0":{"targetAlias":"net7.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net7.0":{"targetAlias":"net7.0","dependencies":{"MediatR":{"target":"Package","version":"[12.1.1, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/usr/local/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"}} | ||
"restore":{"projectUniqueName":"/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj","projectName":"Product.Application","projectPath":"/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj","outputPath":"/Users/macbook/Projects/ProductService/Src/Product.Application/obj/","projectStyle":"PackageReference","originalTargetFrameworks":["net7.0"],"sources":{"https://api.nuget.org/v3/index.json":{}},"frameworks":{"net7.0":{"targetAlias":"net7.0","projectReferences":{}}},"warningProperties":{"warnAsError":["NU1605"]}}"frameworks":{"net7.0":{"targetAlias":"net7.0","dependencies":{"FluentValidation":{"target":"Package","version":"[11.9.0, )"},"MediatR":{"target":"Package","version":"[12.1.1, )"}},"imports":["net461","net462","net47","net471","net472","net48","net481"],"assetTargetFallback":true,"warn":true,"frameworkReferences":{"Microsoft.NETCore.App":{"privateAssets":"all"}},"runtimeIdentifierGraphPath":"/usr/local/share/dotnet/sdk/7.0.101/RuntimeIdentifierGraph.json"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16980846711026383 | ||
17088716062586781 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16980846711016059 | ||
17088716062584938 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16980846710948453 | ||
17088716062589583 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16980846711025474 | ||
17088716062591402 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16982528223799853 | ||
17088716063485879 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16982527597733111 | ||
17088716063478327 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16982527748488714 | ||
17088716063485559 |
2 changes: 1 addition & 1 deletion
2
Tests/Product.Infrastructure.Tests/obj/rider.project.restore.info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
16982527967448123 | ||
17088716063484379 |