TGViewer
Programming & AI Tips 💡 Programming & AI Tips 💡 @programmingtip · 46.3K subscribers
Post #363 3.03K
Fluent Validation ⚠️

A small validation library for .NET that uses a fluent interface and lambda expressions for building validation rules. 🚫

NuGet Packages :
Install-Package FluentValidation


For ASP.NET MVC integration :
Install-Package FluentValidation.MVC5


For ASP.NET Core :
Install-Package FluentValidation.AspNetCore


🔹🔸🔹🔸

Example :

public class PersonValidator : AbstractValidator<Person>
{
public PersonValidator()
{
RuleFor(x => x.ID).NotEmpty();

RuleFor(x => x.FirstName)
.NotEmpty()
.WithMessage("{PropertyName} is required !")
.MinimumLength(5)
.WithMessage("Minimum length for {PropertyName} is {MinLength} !");

RuleFor(x => x.LastName)
.NotEmpty()
.WithMessage("{PropertyName} is required !")
.MinimumLength(5)
.WithMessage("Minimum length for {PropertyName} is {MinLength} !");

RuleFor(x => x.Email)
.NotEmpty()
.WithMessage("{PropertyName} is required !")
.EmailAddress()
.WithMessage("{PropertyName} is not valid !");
}
}


🔹🔸🔹🔸

https://t.me/pgimg/78

[ Github ] : http://bit.do/flval

〰〰〰〰〰〰
#CSharp #AspMvc #Validation
@ProgrammingTip
Telegram Programming Tips Resources
More from @programmingtip
  1. Oct 6, 2026Cloudflare shipped a Web Search API ⚡️ Cloudflare introduced a Web Search API. Search can…
  2. Oct 5, 2026AI is changing the developer career ladder 🚀 GitHub's latest developer career advice is r…
  3. Oct 2, 2026GPT-6 Astra gets an Ultrafast API tier 🚀 OpenAI added an Ultrafast speed tier for GPT-6 A…
  4. Oct 1, 2026Cloudflare shipped an agentic CLI for its API ⚡️ Cloudflare launched cf, an agentic CLI fo…
  5. Sep 30, 2026OpenAI introduced Dots, always-on agents 🚀 OpenAI introduced Dots, its take on always-on…
  6. Sep 29, 2026Claude Sonnet 5.5 is built for coding agents 🚀 Anthropic released Claude Sonnet 5.5 for t…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →