From 30eb0398353779a8d3caec4f06c24db03da827ab Mon Sep 17 00:00:00 2001 From: CodeAnt AI Date: Thu, 10 Apr 2025 11:56:23 +0000 Subject: [PATCH] changed files --- .../Common/Behaviours/ValidationBehaviour.cs | 12 ++++++++++++ .../CreateWeatherForecastCommandValidator.cs | 17 +++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Samples/SampleNET7.Application/Common/Behaviours/ValidationBehaviour.cs b/Samples/SampleNET7.Application/Common/Behaviours/ValidationBehaviour.cs index 715e622..a954552 100644 --- a/Samples/SampleNET7.Application/Common/Behaviours/ValidationBehaviour.cs +++ b/Samples/SampleNET7.Application/Common/Behaviours/ValidationBehaviour.cs @@ -14,6 +14,18 @@ public ValidationBehaviour(IEnumerable> validators) _validators = validators; } + /// + /// Handles the validation for a given request and proceeds to the next handler if validation succeeds. + /// + /// The request instance to validate. + /// The delegate to execute the next handler. + /// The cancellation token to observe while waiting for the task to complete. + /// The response from the next handler. + /// Thrown when one or more validation failures occur. + /// + /// var response = await handleInstance.Handle(request, nextHandler, cancellationToken); + /// Console.WriteLine(response); // The expected response if validation passes. + /// public async Task Handle(TRequest request, RequestHandlerDelegate next, CancellationToken cancellationToken) { if (_validators.Any()) diff --git a/Samples/SampleNET7.Application/Messages/Commands/CreateWeatherForecastCommandValidator.cs b/Samples/SampleNET7.Application/Messages/Commands/CreateWeatherForecastCommandValidator.cs index 6451672..206dd57 100644 --- a/Samples/SampleNET7.Application/Messages/Commands/CreateWeatherForecastCommandValidator.cs +++ b/Samples/SampleNET7.Application/Messages/Commands/CreateWeatherForecastCommandValidator.cs @@ -4,6 +4,23 @@ namespace SampleNET7.Application.Messages.Commands; public class CreateWeatherForecastCommandValidator : AbstractValidator { + /// + /// Initializes a new instance of the class, + /// setting up validation rules for various properties of the CreateWeatherForecastCommand. + /// It ensures that certain fields such as Summaries and NotNullableString are not empty. + /// + /// + /// var validator = new CreateWeatherForecastCommandValidator(); + /// var result = validator.Validate(createWeatherForecastCommand); + /// if (result.IsValid) + /// { + /// // Process the valid command + /// } + /// else + /// { + /// // Handle validation failures + /// } + /// public CreateWeatherForecastCommandValidator() {