Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,18 @@ public ValidationBehaviour(IEnumerable<IValidator<TRequest>> validators)
_validators = validators;
}

/// <summary>
/// Handles the validation for a given request and proceeds to the next handler if validation succeeds.
/// </summary>
/// <param name="request">The request instance to validate.</param>
/// <param name="next">The delegate to execute the next handler.</param>
/// <param name="cancellationToken">The cancellation token to observe while waiting for the task to complete.</param>
/// <returns>The response from the next handler.</returns>
/// <exception cref="ValidationException">Thrown when one or more validation failures occur.</exception>
/// <example>
/// var response = await handleInstance.Handle(request, nextHandler, cancellationToken);
/// Console.WriteLine(response); // The expected response if validation passes.
/// </example>
public async Task<TResponse> Handle(TRequest request, RequestHandlerDelegate<TResponse> next, CancellationToken cancellationToken)
{
if (_validators.Any())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,23 @@ namespace SampleNET7.Application.Messages.Commands;

public class CreateWeatherForecastCommandValidator : AbstractValidator<CreateWeatherForecastCommand>
{
/// <summary>
/// Initializes a new instance of the <see cref="CreateWeatherForecastCommandValidator"/> class,
/// setting up validation rules for various properties of the CreateWeatherForecastCommand.
/// It ensures that certain fields such as Summaries and NotNullableString are not empty.
/// </summary>
/// <example>
/// var validator = new CreateWeatherForecastCommandValidator();
/// var result = validator.Validate(createWeatherForecastCommand);
/// if (result.IsValid)
/// {
/// // Process the valid command
/// }
/// else
/// {
/// // Handle validation failures
/// }
/// </example>
public CreateWeatherForecastCommandValidator()
{

Expand Down
Loading