I am very new to Fluent Validation and C# programming
Below is my validator:
Below is my validator:
public CustomerValidator()
{
When(customer => customer.IsPreferredCustomer, () =>
{
RuleFor(customer => customer.Discount).GreaterThan(0);
});
}
Here is how I validate data. But inspite of isPreferredCustomer set to false, the results.isValid = true. Am I missing anything Customer customer = new Customer();
customer.Id = 13;
customer.Surname = "foo";
customer.Forename = "Abcs";
customer.Discount = 2;
customer.Address = "23 abc drive, hilton, ak";
customer.IsPreferredCustomer = false;
CustomerValidator validator = new CustomerValidator();
var results = validator.Validate(customer);