I have a fluent validation implemented in my WebAPI:
/// <summary>
/// This class encapsulates the rules to validate a <see cref="PingPongEndpointRequest"/>.
/// </summary>
public class PingPongValidator : Validator<PingPongEndpointRequest>
{
/// <summary>
/// The concrete validation rule.
/// </summary>
public PingPongValidator()
{
RuleFor(x => x.Text)
.NotEmpty().WithMessage("PingPong Text should not be empty");
}
}
Now I want to do a duplicate check, e.g. when an user will register on my app, I want to check if the email is already taken. For that ofc I need the dbcontext etc.
Is the fluent validation still the “right” point where to do that?
Or would I do that in my service / domain-layer, because it is bad practice to have database requests in the fluent validation?