Mid
ASP.NET Core
ASP.NET Core
Using FluentValidation?
- Install FluentValidation.AspNetCore
- Create a validator class:
public class UserValidator : AbstractValidator<User> {
public UserValidator() {
RuleFor(x => x.Email).NotEmpty().EmailAddress();
}
}
Register with:
services.AddFluentValidationAutoValidation();
✅ Offers more readable and testable validation logic than data annotations.
Share this Q&A
Share preview image: https://www.toolliyo.com/images/toolliyo-logo.png