Menu
Newbedev LogoNEWBEDEV Python Javascript Linux Cheat sheet
Newbedev LogoNEWBEDEV
  • Python 1
  • Javascript
  • Linux
  • Cheat sheet
  • Contact

How to use FluentValidation.AspNetCore and FluentValidation.MVC6?

This is working for me:

project.json add:

"FluentValidation.AspNetCore": "6.4.0-beta3"

startup.cs

services
.AddMvc()
.AddFluentValidation(fv => fv.RegisterValidatorsFromAssemblyContaining<Startup>());

Validation:

public class Foo
{
     public string Bar {get; set;}
}

public class FooValidator : AbstractValidator<Foo> 
{
    public FooValidator()
    { 
        RuleFor(x => x.Bar).NotEmpty().WithMessage("Error Message");
    }
}

Tags:

Fluentvalidation

Asp.Net Core

Related

Unit testing click event in Angular Call another click command from a click command Ionic 2 placeholder text styling Simulate click event on react element Android Camera2 API YUV_420_888 to JPEG PostCSS error: [object Object] is not a PostCSS plugin Django (1.10) override AdminSite DataGrip added value compared to IntelliJ IDEA Calling Fortran subroutines with optional arguments from C++ Add swipe right to delete ListView item EXCEPTION: Root segment cannot have matrix parameters How to add a dependency to a Spring Boot Jar in another project?

Recent Posts

Pandas how to find column contains a certain value Recommended way to install multiple Python versions on Ubuntu 20.04 Build super fast web scraper with Python x100 than BeautifulSoup How to convert a SQL query result to a Pandas DataFrame in Python How to write a Pandas DataFrame to a .csv file in Python
© 2021 newbedevPrivacy Policy