I'm using the MVC core template and try to implement FluentValidation. I've installed the package Abp.FluentValidation and set the DependsOn attribute for the type AbpFluentValidationModule at the WebCoreModule class.
I've added the validator class below for the input class of a service but seems not to validate, any value for NumberOfUnits is valid.
class CreateOrEditUnitDtoValidator : AbstractValidator<CreateOrEditUnitDto>
{
public CreateOrEditUnitDtoValidator()
{
RuleFor(x => x.NumberOfUnits).GreaterThanOrEqualTo(10);
}
}
Do I miss something or is the fluent validation not working on services?
3 Answer(s)
-
0
The CreateOrEditUnitDtoValidator class should be public.
-
0
The validator class should be public, but the other thing is that the validator class should be placed in solutionname.Application project instead of the solutionname.Application.Shared where the dto's are located.
After moving the validator class and making it public the validation is working, thanks for your help.
-
0
thanks for the feedback