jbogard / MediatR

Simple, unambitious mediator implementation in .NET
Apache License 2.0
11.19k stars 1.18k forks source link

Validation is not invoked when IRequest has no Result #1049

Closed Balirezaei closed 4 months ago

Balirezaei commented 4 months ago

Hi In Dot Net SDK 8 MediatR 12.2

This code is working properly `

public class UpdateTodoListCommandValidator : AbstractValidator<UpdateTodoListCommand>
{
    public UpdateTodoListCommandValidator()
    {
        RuleFor(v => v.Title)
            .NotEmpty()
            .MaximumLength(200);
    }
}

public record UpdateTodoListCommand : IRequest<int>
{
    public int Id { get; init; }

    public string? Title { get; init; }
}

public class UpdateTodoListCommandHandler : IRequestHandler<UpdateTodoListCommand,int>
{
    public async Task<int> Handle(UpdateTodoListCommand request, CancellationToken cancellationToken)
    {
        return 1;
    }
}

`

but when we remove the Irequest Result (In this example (int)) Validation is not fired.

image

Kind regards and thanks for a fantastic free tool.