You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the solution, project HttpApi, i´ve created a controller, and endpoint input class and the the validator.
The behavior expect was to the validator be executed for that endpoint.
Here are the steps
publicclassCreateUserValidator:AbstractValidator<CreateUserDto>{publicCreateUserValidator(){RuleFor(x =>x.Name).NotEmpty().WithMessage("The property {PropertyName} is required");}}
Create the controller
[ApiVersion("1.0",Deprecated=false)][ApiController][ControllerName("user")][Route("api/user")]publicclassUserController:MyDemoController{[HttpPost()]publicvirtualasyncTask<IActionResult>CreateUser(FromBody] CreateUserDto input){// do something to create the userreturnOk();}}
In the HttpApi module classe use the AbpFluentValidationModule to be depends on it.
Those are the steps.
But only worked for me if i follow the official documentation of FluenValidation.
By instaling FluentValidation.AspNetCore
And in the module ConfigureServices method, execute that:
Looks like FluentValidation doesnt work with Asp. Net conventional controllers.
There is something else that i must do to make it work?
Or should i and use the official approach of FluentValidation to setup correctly?
Thanks
The text was updated successfully, but these errors were encountered: