Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validation is not invoked when IRequest has no Result #1049

Closed
Balirezaei opened this issue Jul 9, 2024 · 0 comments
Closed

Validation is not invoked when IRequest has no Result #1049

Balirezaei opened this issue Jul 9, 2024 · 0 comments

Comments

@Balirezaei
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant