-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Volo.Abp.FluentValidation Package seems to not be working #19909
Comments
This is because you are using the conventional controllers. ABP uses interceptors for parameter validation, but does not intercept controllers for performance. abp/framework/src/Volo.Abp.AspNetCore.Mvc/Volo/Abp/AspNetCore/Mvc/AbpAspNetCoreMvcModule.cs Lines 221 to 223 in 4f28255
abp/framework/src/Volo.Abp.Validation/Volo/Abp/Validation/ValidationInterceptorRegistrar.cs Line 19 in 4f28255
In order to use FluentValidation, you can't use a convention controller, you need to create one manually. For example: abp/modules/identity/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs Line 14 in 4f28255
|
And please make the repo private |
You can add an JadynWong/AbpIssue@eec5290#diff-e7c9195c610944a0f739a7bca415e73d593bdd5712205d1b8322af4aedb8e0dd
Only basic tests were performed. It would be better if abp could provide built-in support. |
This solution seems to be working for now, thank you @JadynWong |
Is there an existing issue for this?
Description
I am currently trying to use the
Volo.Abp.FluentValidation
package following what is outlined in the documentation here.Currently it seems that anything I define in my validator classes is not being picked up.
Reproduction Steps
I have created a sample project showcasing this not working here:
Github Repo
I used the started template, added one model and an appservice to showcase this behavior. I have also added API versioning as that is a requirement that I need to have working with this.
Expected behavior
FluentValidation package to detect any class using/inheriting from
AbstractValidator<>
and correctly triggering the rules defined.Actual behavior
I have defined the following for My
CreateBookDto
Validation:So I expect to get validation errors for all of the properties here when I try creating a new Book. Instead I receive the following:
I don't receive errors about the missing properties and even the message for the
name
field is wrong. This indicates that FluentValidations are not triggering.Regression?
No response
Known Workarounds
No response
Version
8.1.3
User Interface
Common (Default)
Database Provider
EF Core (Default)
Tiered or separate authentication server
Tiered
Operation System
Windows (Default)
Other information
No response
The text was updated successfully, but these errors were encountered: