diff --git a/Src/Product.API/obj/rider.project.restore.info b/Src/Product.API/obj/rider.project.restore.info index 1af2077..0ea6103 100644 --- a/Src/Product.API/obj/rider.project.restore.info +++ b/Src/Product.API/obj/rider.project.restore.info @@ -1 +1 @@ -16980846711034705 \ No newline at end of file +17088716062710207 \ No newline at end of file diff --git a/Src/Product.Application/Product.Application.csproj b/Src/Product.Application/Product.Application.csproj index dac2cc7..38f8a1f 100644 --- a/Src/Product.Application/Product.Application.csproj +++ b/Src/Product.Application/Product.Application.csproj @@ -7,6 +7,7 @@ + diff --git a/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandHandler.cs b/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandHandler.cs index 52e60f1..678bf40 100644 --- a/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandHandler.cs +++ b/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandHandler.cs @@ -1,11 +1,18 @@ +using FluentValidation; using MediatR; namespace Product.Application.Product.Commands; public sealed class CreateProductCommandHandler : IRequestHandler { - public Task Handle(CreateProductCommand request, CancellationToken cancellationToken) + private readonly IValidator _validator; + public CreateProductCommandHandler(IValidator validator) { + _validator = validator; + } + public Task Handle(CreateProductCommand command, CancellationToken cancellationToken) + { + _validator.ValidateAndThrow(command); throw new NotImplementedException(); } } \ No newline at end of file diff --git a/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandValidator.cs b/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandValidator.cs index 9850f5e..6b55e72 100644 --- a/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandValidator.cs +++ b/Src/Product.Application/Product/Commands/CreateProduct/CreateProductCommandValidator.cs @@ -1,6 +1,26 @@ +using FluentValidation; + namespace Product.Application.Product.Commands; -public class CreateProductCommandValidator +public class CreateProductCommandValidator : AbstractValidator { - + 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."); + } } \ No newline at end of file diff --git a/Src/Product.Application/obj/Debug/net7.0/Product.Application.assets.cache b/Src/Product.Application/obj/Debug/net7.0/Product.Application.assets.cache index 405520e..9d36e65 100644 Binary files a/Src/Product.Application/obj/Debug/net7.0/Product.Application.assets.cache and b/Src/Product.Application/obj/Debug/net7.0/Product.Application.assets.cache differ diff --git a/Src/Product.Application/obj/Debug/net7.0/Product.Application.csproj.AssemblyReference.cache b/Src/Product.Application/obj/Debug/net7.0/Product.Application.csproj.AssemblyReference.cache index 1252bd1..113564a 100644 Binary files a/Src/Product.Application/obj/Debug/net7.0/Product.Application.csproj.AssemblyReference.cache and b/Src/Product.Application/obj/Debug/net7.0/Product.Application.csproj.AssemblyReference.cache differ diff --git a/Src/Product.Application/obj/Product.Application.csproj.nuget.dgspec.json b/Src/Product.Application/obj/Product.Application.csproj.nuget.dgspec.json index 6011138..be50cbb 100644 --- a/Src/Product.Application/obj/Product.Application.csproj.nuget.dgspec.json +++ b/Src/Product.Application/obj/Product.Application.csproj.nuget.dgspec.json @@ -38,6 +38,10 @@ "net7.0": { "targetAlias": "net7.0", "dependencies": { + "FluentValidation": { + "target": "Package", + "version": "[11.9.0, )" + }, "MediatR": { "target": "Package", "version": "[12.1.1, )" diff --git a/Src/Product.Application/obj/project.assets.json b/Src/Product.Application/obj/project.assets.json index 024d95a..321d6a2 100644 --- a/Src/Product.Application/obj/project.assets.json +++ b/Src/Product.Application/obj/project.assets.json @@ -2,6 +2,19 @@ "version": 3, "targets": { "net7.0": { + "FluentValidation/11.9.0": { + "type": "package", + "compile": { + "lib/net7.0/FluentValidation.dll": { + "related": ".xml" + } + }, + "runtime": { + "lib/net7.0/FluentValidation.dll": { + "related": ".xml" + } + } + }, "MediatR/12.1.1": { "type": "package", "dependencies": { @@ -51,6 +64,31 @@ } }, "libraries": { + "FluentValidation/11.9.0": { + "sha512": "VneVlTvwYDkfHV5av3QrQ0amALgrLX6LV94wlYyEsh0B/klJBW7C8y2eAtj5tOZ3jH6CAVpr4s1ZGgew/QWyig==", + "type": "package", + "path": "fluentvalidation/11.9.0", + "files": [ + ".nupkg.metadata", + ".signature.p7s", + "README.md", + "fluent-validation-icon.png", + "fluentvalidation.11.9.0.nupkg.sha512", + "fluentvalidation.nuspec", + "lib/net5.0/FluentValidation.dll", + "lib/net5.0/FluentValidation.xml", + "lib/net6.0/FluentValidation.dll", + "lib/net6.0/FluentValidation.xml", + "lib/net7.0/FluentValidation.dll", + "lib/net7.0/FluentValidation.xml", + "lib/net8.0/FluentValidation.dll", + "lib/net8.0/FluentValidation.xml", + "lib/netstandard2.0/FluentValidation.dll", + "lib/netstandard2.0/FluentValidation.xml", + "lib/netstandard2.1/FluentValidation.dll", + "lib/netstandard2.1/FluentValidation.xml" + ] + }, "MediatR/12.1.1": { "sha512": "1AbwzzeS6gn4NdcO6A9LfKS5TXXgAiUQM3J18dREHa7O7TrdCXJ5dNFeRBpzPZY7UWl5Kby+n9pWrPJe3SDiMA==", "type": "package", @@ -109,6 +147,7 @@ }, "projectFileDependencyGroups": { "net7.0": [ + "FluentValidation >= 11.9.0", "MediatR >= 12.1.1" ] }, @@ -149,6 +188,10 @@ "net7.0": { "targetAlias": "net7.0", "dependencies": { + "FluentValidation": { + "target": "Package", + "version": "[11.9.0, )" + }, "MediatR": { "target": "Package", "version": "[12.1.1, )" diff --git a/Src/Product.Application/obj/project.nuget.cache b/Src/Product.Application/obj/project.nuget.cache index 6dea78d..11dfe0e 100644 --- a/Src/Product.Application/obj/project.nuget.cache +++ b/Src/Product.Application/obj/project.nuget.cache @@ -1,9 +1,10 @@ { "version": 2, - "dgSpecHash": "dOjFLWHI6F9yGwMa4Fcb7kIkeWN16oW8Vgte7gAFoH06Ca6L0sY5QKAWKePsQAUwt5Nbht2mqx7L68gWMZooIw==", + "dgSpecHash": "FJnjtZBeNcJKOQh06yKLmPe9Qf2dIT/hZxgh/hl2NOc+Pw17D1ZN0ea4YHyI++/BBS87ysV9mmsyUMLDJStPOQ==", "success": true, "projectFilePath": "/Users/macbook/Projects/ProductService/Src/Product.Application/Product.Application.csproj", "expectedPackageFiles": [ + "/Users/macbook/.nuget/packages/fluentvalidation/11.9.0/fluentvalidation.11.9.0.nupkg.sha512", "/Users/macbook/.nuget/packages/mediatr/12.1.1/mediatr.12.1.1.nupkg.sha512", "/Users/macbook/.nuget/packages/mediatr.contracts/2.0.1/mediatr.contracts.2.0.1.nupkg.sha512", "/Users/macbook/.nuget/packages/microsoft.extensions.dependencyinjection.abstractions/6.0.0/microsoft.extensions.dependencyinjection.abstractions.6.0.0.nupkg.sha512" diff --git a/Src/Product.Application/obj/project.packagespec.json b/Src/Product.Application/obj/project.packagespec.json index 1c6f41b..03b4543 100644 --- a/Src/Product.Application/obj/project.packagespec.json +++ b/Src/Product.Application/obj/project.packagespec.json @@ -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"}} \ No newline at end of file +"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"}} \ No newline at end of file diff --git a/Src/Product.Application/obj/rider.project.restore.info b/Src/Product.Application/obj/rider.project.restore.info index 3ccb1b8..6a127e3 100644 --- a/Src/Product.Application/obj/rider.project.restore.info +++ b/Src/Product.Application/obj/rider.project.restore.info @@ -1 +1 @@ -16980846711026383 \ No newline at end of file +17088716062586781 \ No newline at end of file diff --git a/Src/Product.Domain/obj/rider.project.restore.info b/Src/Product.Domain/obj/rider.project.restore.info index 2c8bf9b..e4d4724 100644 --- a/Src/Product.Domain/obj/rider.project.restore.info +++ b/Src/Product.Domain/obj/rider.project.restore.info @@ -1 +1 @@ -16980846711016059 \ No newline at end of file +17088716062584938 \ No newline at end of file diff --git a/Src/Product.Infrastructure/obj/rider.project.restore.info b/Src/Product.Infrastructure/obj/rider.project.restore.info index 1398889..8582a15 100644 --- a/Src/Product.Infrastructure/obj/rider.project.restore.info +++ b/Src/Product.Infrastructure/obj/rider.project.restore.info @@ -1 +1 @@ -16980846710948453 \ No newline at end of file +17088716062589583 \ No newline at end of file diff --git a/Src/Product.Ioc/obj/rider.project.restore.info b/Src/Product.Ioc/obj/rider.project.restore.info index a5a7e87..4e50649 100644 --- a/Src/Product.Ioc/obj/rider.project.restore.info +++ b/Src/Product.Ioc/obj/rider.project.restore.info @@ -1 +1 @@ -16980846711025474 \ No newline at end of file +17088716062591402 \ No newline at end of file diff --git a/Tests/Product.Api.Tests/obj/rider.project.restore.info b/Tests/Product.Api.Tests/obj/rider.project.restore.info index b84c850..b629624 100644 --- a/Tests/Product.Api.Tests/obj/rider.project.restore.info +++ b/Tests/Product.Api.Tests/obj/rider.project.restore.info @@ -1 +1 @@ -16982528223799853 \ No newline at end of file +17088716063485879 \ No newline at end of file diff --git a/Tests/Product.Application.Tests/obj/rider.project.restore.info b/Tests/Product.Application.Tests/obj/rider.project.restore.info index b76c05f..0c5a41b 100644 --- a/Tests/Product.Application.Tests/obj/rider.project.restore.info +++ b/Tests/Product.Application.Tests/obj/rider.project.restore.info @@ -1 +1 @@ -16982527597733111 \ No newline at end of file +17088716063478327 \ No newline at end of file diff --git a/Tests/Product.Domain.Tests/obj/rider.project.restore.info b/Tests/Product.Domain.Tests/obj/rider.project.restore.info index 89816e4..c929c48 100644 --- a/Tests/Product.Domain.Tests/obj/rider.project.restore.info +++ b/Tests/Product.Domain.Tests/obj/rider.project.restore.info @@ -1 +1 @@ -16982527748488714 \ No newline at end of file +17088716063485559 \ No newline at end of file diff --git a/Tests/Product.Infrastructure.Tests/obj/rider.project.restore.info b/Tests/Product.Infrastructure.Tests/obj/rider.project.restore.info index 4ae67d9..2159824 100644 --- a/Tests/Product.Infrastructure.Tests/obj/rider.project.restore.info +++ b/Tests/Product.Infrastructure.Tests/obj/rider.project.restore.info @@ -1 +1 @@ -16982527967448123 \ No newline at end of file +17088716063484379 \ No newline at end of file