public class UserValidator : AbstractValidator{ public UserValidator() { RuleFor(user => user.Email).NotNull(); } } var user = new User(); var validator = new UserValidator(); // Add new validation rule validator.AddOrUpdate(user => user.FirstName, rule => rule.NotNull());
public class UserValidator : AbstractValidatorThe package library for FluentValidation can be found on NuGet - https://www.nuget.org/packages/FluentValidation/{ public UserValidator() { RuleFor(user => user.Email).NotNull(); } } var user = new User(); var validator = new UserValidator(); // Update existing validation rule validator.AddOrUpdate(user => user.Email, rule => rule.NotNull().NotEmpty());