Open Closed

FluentValidation in Blazor server #8499


User avatar
0
castellazzi created
  • ABP Framework version: v9.0.0
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server .)

I have a question about FluentValidation in Blazor server. I use it with package Blazorise.FluentValditation, and also adding Volo.Abp.FluentValidation. I notice 2 problem:

  1. message from validator is not from abp.validation
  2. name of field using in message is the property name. I fix the property using WithName method on method, for the message is need to fix it with WithMessage method? This is an example: There are a best pratice for using with Abp and FluentValidation and blazorise? Many thanks Marco

2 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    It works for me

    • create a new project with blazor-server
    • install Blazorise.FluentValidation and FluentValidation.DependencyInjectionExtensions to Blazor project
    • install Volo.Abp.FluentValidation to Application project

    Configure

        [DependsOn(
           ......
            typeof(AbpFluentValidationModule)
        )]
    public class TestappApplicationModule : AbpModule
    
    context.Services
        .AddBootstrap5Providers()
        .AddFontAwesomeIcons()
        .AddBlazoriseFluentValidation();
    
    context.Services.AddValidatorsFromAssembly(typeof(TestappApplicationModule).Assembly);
    

    name of field using in message is the property name. I fix the property using WithName method on method, for the message is need to fix it with WithMessage method? This is an example:

    You have to use WithName

  • User Avatar
    0
    castellazzi created

    Ok. Ii's work also for me. Thanks,

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 13, 2025, 04:08