I'm using FluentValidation 11.5.1. I don't want to use:
// MapPost //
public static void AddUser([FromBody] UserRequest, [FromServices] IValidator<UserRequest> validator)
I want it to be automatic:
public static void AddUser([FromBody] UserRequest)
{
If it will fail, it would show the errors and wouldn't get here,
Without to injecting the validator.
}
in Program.cs, I have used:
services.AddMvc().AddFluentValidation() - it's deprecated and minimal api is not mvc.
And it didn't work.
- How the validator can validate automatically the request without injecting the validator?
- Request from client side -> EndPoint: AddUser([FromBody] UserRequest) -> Incase it will not pass the validation you will get an errors from FluentValidation without "[FromServices] IValidator validator" injecting the validator in the endpoint, kinda like in Data Annotations.